SOLVED: How to jQuery-ify elements returned by ajax call? -


i ask question in drupal context, answer may generic , not depend on drupal.

i have html elements updated/replaced via jquery/ajax. on first page load, elements processed jquery. however, links included in data returned after ajax call ignored jquery.

// standard function ensures elements processed after first page load:    drupal.behaviors.events = function(context) {     // works intended. clicking on links works intended:    $('.event_browse_location .parent_locations a:not(.events-processed)', context).addclass('events-processed')     .bind('click', function() {       $.get(drupal.settings.basepath + '/events/location/' + parseint(this.id, 10), null, browselocation);         return false;   }); }                                     var browselocation = function(response) {   var result = drupal.parsejson(response);                                             // new elements added dom here:   $('.event_browse_location').html(result.data);     // however, not seem have effect.    // elements in new elements not work intended.    // jquery not process them @ all.   $('.event_browse_location .parent_locations a:not(.events-processed)').addclass('events-processed')     .bind('click', function() {       $.get(drupal.settings.basepath + '/events/location/' + parseint(this.id, 10), null, browselocation);         return false;   }); } 

in case, there 2 silly mistakes.

the first 1 pointed out guest271314: there undeclared variable in original code posted. have amended question accordingly.

secondly, jquery selector wrong , excluding elements meant included. fixing selector fixed problem.


Comments

Popular posts from this blog

how to proxy from https to http with lighttpd -

android - Automated my builds -

python - Flask migration error -