The JQuery popup click function doesn't work after the load more function is placed. Here are the code for popup overlay code

jQuery(document).ready(function() {
//----- OPEN
jQuery('[data-popup-open]').on('click', function(e)  {
    var targeted_popup_class = jQuery(this).attr('data-popup-open');
    jQuery('[data-popup="' + targeted_popup_class + '"]').fadeIn(150);

    e.preventDefault();
});

//----- CLOSE
jQuery('[data-popup-close]').on('click', function(e)  {
    var targeted_popup_class = jQuery(this).attr('data-popup-close');
    jQuery('[data-popup="' + targeted_popup_class + '"]').fadeOut(150);

    e.preventDefault();
});

});

Here are the site i'm working in https://mypencilboxonline.com/upHonest/?q=node/93

Try click on member's name before and after the Load more. The JQuery above doesn't work after the load more. Not sure what's wrong. Any help would be appreciate. Thanks!

Comments

FutureITS created an issue. See original summary.

quicksketch’s picture

Category: Bug report » Support request
Priority: Critical » Normal
Status: Active » Fixed

This is because you're using jQuery(document).ready(function() { to attach your click handler. That event only fires when the document is loaded, not after subsequent changes have been made to the page (like loading in more content via AJAX).

See https://www.lullabot.com/articles/understanding-javascript-behaviors-in-... for a tutorial on how to use behaviors (they're actually really easy) instead of using $(document).ready().

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.