javascript - Click handler fired only once -


i have set of links iterate on , add click handlers. each link when clicked, fires ajax request upon success creates div containing response data, , appends dom. newly appended div (a floating div similar small lightbox) however, removed when user clicks close(on div) or clicks anywhere else on screen. have simple script below monitor change, click handler fires once , not work until after page refresh. doing incorrectly?

var monitorchange = function () {     //check if div has been appended dom , if continue monitor     if ( $('div.justappended').length > 0 )      {         settimeout(monitorchange,100);     }      else      {         //div has been removed dom         alert('div removed');         //...do additional stuff here     } };  $( 'span.someelements' ).each( function () {     var = $(this);     $(that).click( monitorchange ); }); 

from understand, looking have on click event still work ajax generated code. need use live command in case. http://api.jquery.com/live/

$('span.someelements').live('click', monitorchange);


Comments

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -