requirejs - view events are set twice when I instantiate view second time -
requirejs - view events are set twice when I instantiate view second time -
this project architecture issue - first backbone project , did wrong.
in project in route callbacks have:
myroute: function() { this.currentview = new mycustomview(); }, mysecondroute: function() { this.currentview = new mysecondview() }, //...
so in route callbacks instantiate view. view has initialze method calls render method. works except view events (declared in events: {}
) 'binded' every time same view instantiated. when visit same route twice events view corresponding route fired twice...
probably shouldn instantiate new view on every route phone call - how can ? mean standards? maybe should unload current view somehow - there method this?
i think have add together method unbind events @ time close view
like this
close : function () { //your code clean before closing view this.remove(); this.unbind(); }
so next time view called events added during initialization of view, thats why had events beingness called twice. initialize method binds events .el element. need create sure unbind @ point.
requirejs
Comments
Post a Comment