backbone.js events not firing after re-render

前端 未结 4 548
孤城傲影
孤城傲影 2020-12-24 07:08

[EDIT: I solved earlier problem by calling delegateEvents(), but shouldn\'t have to. Re-posting w/more info.]

I have a View that when rendered has a login button on

4条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-24 07:50

    You empty the the #login div. As the jQuery doc says:

    To avoid memory leaks, jQuery removes other constructs such as data and event handlers from the child elements before removing the elements themselves.

    So you are effectively removing events from your views. I prefer to use detach because it keeps events. http://api.jquery.com/detach/

    You can implement a show/hide in your views that will deal with this.

提交回复
热议问题