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

Popular posts from this blog

web services - java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer -

Accessing MATLAB's unicode strings from C -

javascript - mongodb won't find my schema method in nested container -