3

I have a views with ajax enabled using B.E.F. to filter some content. After submitting these filters jquery scripts stop working. Please help me to find an answer how to reload any of these scripts after using submit button with ajax? I`ve tried to do something like this and load it as a simple script using drupal_add_js in template.php:

Drupal.Behaviors.reload = function (context) {
jQuery(".form-submit").submit(function() {
  jQuery("table").stickyTableHeaders();
});
}

I know that this code can hardly work but still firebug says Drupal.Behaviors is undefined.

2

If you wrote your JS code like this.

(function ($) {
  Drupal.behaviors.tableStickHeaders = {
    attach: function(context, settings) {
      $("table").stickyTableHeaders();
    }
  };
})(jQuery);

It should automatically be reapplied when needed. This is the recommended way if writing JavaScript for Drupal.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.