backbone.js events not firing after re-render

前端 未结 4 536
孤城傲影
孤城傲影 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:55

    When using $(el).empty() it removes all the child elements in the selected element AND removes ALL the events (and data) that are bound to any (child) elements inside of the selected element (el).

    To keep the events bound to the child elements, but still remove the child elements, use:

    $(el).children().detach(); instead of $(.el).empty();

    This will allow your view to rerender successfully with the events still bound and working.

提交回复
热议问题