2

i have a script for dealing with node images hover

(function ($) {
    $(function(){

    $('.node-photos-teaser').mouseenter(function() {
        $(this).addClass('photos-hover');
    }).mouseleave(function() {
        $(this).removeClass('photos-hover');
    });     


});
})(jQuery);

when clicking on a node filter set by 'better_exposed_filters' using ajax, the POST drupal/views/ajax?field_tags_tid_1=4 is loaded and filter out nodes fine but the JQuery behaviour is working nomore.

Ajax breaks jquery

Any help?

1

Thanks to Clive answer i have solved out the problem embedding to my theme script file :

 Drupal.behaviors.betterExposedFilters = {
    attach: function(context) {  }}

now having:

 (function ($) {
Drupal.behaviors.betterExposedFilters = {
        attach: function(context) {         

    $('.node-photos-teaser').mouseenter(function() {
        $(this).addClass('photos-hover');
    }).mouseleave(function() {
        $(this).removeClass('photos-hover');
    });


        }}
})(jQuery);

renders compatible the JQuery from my theme with ajax from betterExposedFilter module

  • Hello @matoeil . can you plz tell me how can I do this without using better-exposed filters in Drupal 8 – Optimum Creative Sep 5 at 12:13

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.