i'm developing plugin generates table rows dynamically display content on defined page, when generating want display button on each row actives ajax request when clicked, i've tried appending id , doing jquery onclick perform this, yet it's not showing test alert()
here's jquery code i'm using :
jquery(document).ready(function(){ jquery("#submit").click(function(event) { //stop form processing event.preventdefault(); //get username value var username = jquery('#username').val(); jquery.ajax({ type: "get", crossdomain: true, url: apiurl + "video/" + username + "/views/", success: function(data) { parsed = jquery.parsejson(data); jquery.each(parsed.user_media, function(i,v){ jquery("#results").append("<tr><td><button type='submit' id='addtoplaylist'>add playlist</button></td></tr>"); }); }, }); }); jquery("#addtoplaylist").click(function(event) { alert('working!'); }); });
everything working perfect such ajax calls , returning table rows, it's when i'm trying utilise .click()
based on <button></button>
doesn't seem activate nor throw errors console.
try this
jquery("#results").on("click", "#addtoplaylist", function(event) { alert('working!'); });
Comments
Post a Comment