jquery - JavaScript event on addition of certain element -


there page list of urls,

when user clicks on 1 of url, jquery modal popup opens list of elements. items in list added dynamically doing ajax call.

each item in list has raty & timeago (both jquery plugins){"5 star rating, 2 months ago"}.

now problem - typically execute javascript functions related these plugins @ time of page load in document.ready event.

however, these functions need executed after items added & ready processing.

what name of event handle?

edit:-

easier way visualize : when add comments question on stackoverlow; can see "added 5 minutes ago". part of counting time & showing 'time ago' handled 'time ago' plugin. function (timeago) must executed on on addition of element(comment in case of stackoverflow). want know handle execute function on addition of new element dom tree.

you can use event delegation using jquery on dynamically added elements.

$(document).on('click', '.classname', function(){  }); 

delegated events

delegated events have advantage can process events descendant elements added document @ later time. picking element guaranteed present @ time delegated event handler attached, can use delegated events avoid need attach , remove event handlers, reference.


Comments

Popular posts from this blog

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -

java - JavaFX 2 slider labelFormatter not being used -