diff --git a/misc/ajax.js b/misc/ajax.js index bb4a6e1..cc5ea9f 100644 --- a/misc/ajax.js +++ b/misc/ajax.js @@ -21,25 +21,26 @@ Drupal.settings.urlIsAjaxTrusted = Drupal.settings.urlIsAjaxTrusted || {}; */ Drupal.behaviors.AJAX = { attach: function (context, settings) { + var $context = $(context); // Load all Ajax behaviors specified in the settings. for (var base in settings.ajax) { - if (!$('#' + base + '.ajax-processed').length) { + if (!$context.find('#' + base + '.ajax-processed').length) { var element_settings = settings.ajax[base]; if (typeof element_settings.selector == 'undefined') { element_settings.selector = '#' + base; } - $(element_settings.selector).each(function () { + $context.find(element_settings.selector).each(function () { element_settings.element = this; Drupal.ajax[base] = new Drupal.ajax(base, this, element_settings); }); - $('#' + base).addClass('ajax-processed'); + $context.find('#' + base).addClass('ajax-processed'); } } // Bind Ajax behaviors to all items showing the class. - $('.use-ajax:not(.ajax-processed)').addClass('ajax-processed').each(function () { + $context.find('.use-ajax:not(.ajax-processed)').addClass('ajax-processed').each(function () { var element_settings = {}; // Clicked links look better with the throbber than the progress bar. element_settings.progress = { 'type': 'throbber' }; @@ -55,7 +56,7 @@ Drupal.behaviors.AJAX = { }); // This class means to submit the form to the action using Ajax. - $('.use-ajax-submit:not(.ajax-processed)').addClass('ajax-processed').each(function () { + $context.find('.use-ajax-submit:not(.ajax-processed)').addClass('ajax-processed').each(function () { var element_settings = {}; // Ajax submits specified in this manner automatically submit to the