0

I have custom jQuery that I've added to views filters to my ajax view. When a user selects certain criteria a slideDown and addClass event is triggered and a new set of filters is shown. You can view it here:

https://www.feedingmatters.org/helpful-books

When I click submit the classes that are added to my elements are removed by Drupal. This causes the elements to display: none and now the users can no longer see their filter trail. How can I either stop Drupal from clearing my addClass? The filters need to remain visible so long as the correct criteria are selected.

Note: I tried views dependent filters but it doesn't work as needed.

1 Answer 1

1

I struggled with this recently in this question

The answer is to wrap your jQuery in a Drupal Behaviour so that the classes are not removed on every ajax request. Because your current jQuery is probably only run on the first page load.

(function($) {
Drupal.behaviors.myBehavior = {
  attach: function (context, settings) {

        // Put your jQuery Code Here

  }
};
})(jQuery);
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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