JQuery: How to attach event to template objects? -
i have template generates images , binding div.
<script id="posttemplate" type="text/html"> <div class="post_1"> <div class="postimage"><img src="${imageurl}" alt="image"></div> </div> </script> then bind data
<script> $("#posttemplate").tmpl(clientdata).appendto("#imagesarea"); </script> now, want add event handlers created. like
("template img").error(function() {}); adding handlers things click seems work, error fires off before can add handler seems.
not sure selector "template img" referencing since dont see template elements.
$(function(){ $('template img').live({ click: function() { // on click }, error: function() { // on error } }); });
Comments
Post a Comment