jquery - How to initialise view again after changin the html -
i have view in backbone.js
app.backbone.userview = backbone.view.extend({ tagname: 'li', classname: 'pp-entry group', template :_.template('<img src="i/pp-pic-8.png" class="pp-pic" alt="" /><a class="pp-pic-wrap show-fb" href="#pp-details-<%=username%>"></a>), templatedetails:_.template('`<div style="display:none"><div id="pp-details-<%=username%>" class="pp-details"><div class="cta clear"><input type="button" name="" value="add wallet" class="mar-right-10 addtowallet" /><input type="button" class="mar-right-10 addtogib" name="" value="add gib link" /><input type="button" name="" value="close" onclick="$.fancybox.close()" /></div></div><.div>'`) //here click event defined events:{ "click .addtowallet":"addlinktowallet", "click .addtogib":"addasgiblink" }, //render contents render: function() { $(this.el).html(this.template(this.model.tojson())); $(this.el).attr('id', 'pp-'+this.model.get('username')); //this used set id "li" tag $(this.el).append(this.templatedetails(this.model.tojson())); //appending template $(".show-fb").fancybox(); }, //but when defining function click event not triggered addasgiblink: function(){ alert("gib button clicked"); }, addlinktowallet: function(){ alert("wallet button clicked"); } });
this html generating . happening here analyise fancy box adding html in div clickevnet on addlinktowallet , other not working . please suggest can make work fancybox ?
<li id="pp-rahul" class="pp-entry group"> <img class="pp-pic" alt="" src="i/pp-pic-8.png"> <a class="pp-pic-wrap show-fb" href="#pp-details-rahul"></a> <div style="display: none;"> // added fancybox <div style="width: auto; height: auto; overflow: auto; position: relative;"> <div id="pp-details-rahul" class="pp-details"> <img class="pp-pic" alt="" src="i/pp-pic-2.png"> <h4 class="pp-name">rahul</h4> <p class="pp-attr"> </p> <p class="pp-attr mar-btm-20"> //here other html coming . </p> <div class="cta clear"> //here html of button </div> </div> </div> </div> </li>
use live()
in view code register click event-
docs- live
Comments
Post a Comment