Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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
Comment #2
quicksketchThis 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().