Skip to main content
added 422 characters in body
Source Link
Clive
  • 167.9k
  • 19
  • 303
  • 337

You're probably just missing the UI button library (libraries are added when they're needed rather than every js file being included for every page).

To fix, add this in your page callback:

drupal_add_library('system', 'ui.button');

To ensure your JS code is invoked after AJAX calls, you just need to wrap it in a Drupal behaviour:

(function($) {
  Drupal.behaviors.myModule = {
    attach: function(context, settings) {
      $('.form-item-service-amount', context).once('mymodule').buttonset();
    }
  };
})(jQuery);

There's no need to use ready() in this context, Drupal will fire attachBehaviors() on document load, and when ajax calls occur, and your module's attach function will be called each time.

once() just makes sure the buttonset is only applied to an individual element once only, to avoid reattaching behaviours to elements that have already had it.

You're probably just missing the UI button library (libraries are added when they're needed rather than every js file being included for every page).

To fix, add this in your page callback:

drupal_add_library('system', 'ui.button');

You're probably just missing the UI button library (libraries are added when they're needed rather than every js file being included for every page).

To fix, add this in your page callback:

drupal_add_library('system', 'ui.button');

To ensure your JS code is invoked after AJAX calls, you just need to wrap it in a Drupal behaviour:

(function($) {
  Drupal.behaviors.myModule = {
    attach: function(context, settings) {
      $('.form-item-service-amount', context).once('mymodule').buttonset();
    }
  };
})(jQuery);

There's no need to use ready() in this context, Drupal will fire attachBehaviors() on document load, and when ajax calls occur, and your module's attach function will be called each time.

once() just makes sure the buttonset is only applied to an individual element once only, to avoid reattaching behaviours to elements that have already had it.

Source Link
Clive
  • 167.9k
  • 19
  • 303
  • 337

You're probably just missing the UI button library (libraries are added when they're needed rather than every js file being included for every page).

To fix, add this in your page callback:

drupal_add_library('system', 'ui.button');