Tell me more ×
Drupal Answers is a question and answer site for Drupal developers and administrators. It's 100% free, no registration required.

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.

share|improve this question

1 Answer

up vote 2 down vote accepted

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.

share|improve this answer
Thanks a lot! I am on my way ;) – Rootical V. Mar 3 '12 at 10:43

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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