javascript - Click Event Not Working After Ajax Content Added -
basically, have page on page loading fetches ajax content. lightbox (which unrelated ajax content) has event.observe
click events stop working when ajax products loaded. can work jquery's .live
method not familiar prototype.
sample not working click event:
event.observe('closelink', 'click', function () { runsomefuntion.close(); clearall(); });
how events (see above) remain functional using prototype, if ajax content added on page load.
event delegation solution. utilize on
. see http://prototypejs.org/learn/event-delegation.
$('ancestorid').on('click', '.closelink', function(event, element) { var clickedlink = event.element; runsomefuntion.close(); clearall(); });
javascript ajax prototypejs
No comments:
Post a Comment