Note that there are some explanatory texts on larger screens.

plurals
  1. PObackbone bind multi event to one button after i new View multi times
    primarykey
    data
    text
    <pre><code>var UserView = Backbone.View.extend({ initialize: function(){ MData.blankHeader.data.topBar.title = '&lt;h1 id="titleLogo"&gt;' + this.options.userName + '&lt;/h1&gt;'; MData.blankHeader.data.topBar.btn1 = ''; MData.blankHeader.data.topBar.btn2 = '&lt;a href="#" id="sendDm" class="cu-round-btn"&gt;发私信&lt;/a&gt;'; $('header').html(Mustache.to_html($('#headerTpl').html(), MData.blankHeader)).append('&lt;div class="topbar-shadow"&gt;&lt;/div&gt;'); $('footer').html(Mustache.to_html($('#footerTpl').html(), MData.eventlistFooter)).attr('id','').find('.selected').removeClass('selected').end().find('.footer-item:eq(3)').addClass('selected'); $('#content').css({"top": $('header').height() + 'px'}); setTimeout(function(){ scrollinit(); },0); onScrollEnd = true;//?? this.render(); }, events:{ "click #sendDm" : "sendDm" }, el: $('body'), sendDm: function(e){ alert('send dm'); e.preventDefault(); }, render: function(){ var html = ""; html += Mustache.to_html($("#userTpl").html(), this.options.userData); $('#pullDown').css("display","none"); $('#ajaxEvent').html(html); console.log(this.options.userId); if(this.options.userName != "me"){ $('#dm').remove(); } calTime(); function calTime(){ _.each($('.user-timeStamp'), function(date){ $(date).html(humaneDate(date.innerHTML)); }); } setInterval(calTime,60000) return this; } }); //code in Router var newUser = new UserCol();//new a Collection newUser.fetch({ data: param, success: function(model,data){ new UserView({userData: data, userId: param}) } }) </code></pre> <p>So when I view this page multi times(change the param in the address bar),the backbone will new the UserView multi times,and the event bind to to button will fire multi time, How Can I make the button just fire one time.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload