javascript - Backbone model change and view render update -


I have an express app with back end session, and in front I have a BABON + requirement I have my problem The session is near the model, and the change event that triggers the render method on ideas.

Such:

  1. The app has a home view, so the session is a listener for the "change" event of the model, and runs the "render" method.
  2. Users with no credentials go from home to a public page, say / talk about /
  3. There, user login (user / password) that entered the entrance.
  4. Due to the listener in item 1, the container element is updated with the new home content, but the user is still about /. So, the question is: How do I avoid this bad behavior so that only the events listen when the right path is active?

    One code example:

      "harsh use"; Var session mode = backbone.model. Extension ({}); Var sessionmodel = new session model (); Var Homeview = Backbone View. Expansion ({initialize: function () {this.listenTo (SessionModel, "change", this.render);}, render: function () {// main container element update}}); Var apprauter = backbone.routor.andand ({"": "home", "about": "about"}); Var appraiser = new apparatus (); AppRouter.on ("route", function () {sessionModel.fetch (); // update session model on each path change}}; AppRouter.on ("route: home", function () {var homeview = new homeview ( ); HomeviewRedder ();});  

Instead of listening, you can listen to a specific feature. / P>

  this.bind ("change: someExpecificThing", doEspecificThing)  

Comments

Popular posts from this blog

java - org.apache.http.ProtocolException: Target host is not specified -

java - Gradle dependencies: compile project by relative path -

ruby on rails - Object doesn't support #inspect when used with .include -