backbone.js - Backbone - before route / view change event -


i want execute method on view before changing other view. example.

var homeview = backbone.view.extend({   ......,    close: function() {  } });  var loginview = backbone.view.extend({   ......     } }); 

if current view "homeview" , if going switch "loginview", need execute close function in homeview before changing loginview. there way?

in other words, view should execute close function automatically before going changed.

i have seen of stackoverflow's previous posts. seems outdated or not useful context.

if use router switch between views:

var homeview = backbone.view.extend({     initialize : function(){         /*             router here references global router object             "route" event triggered when route has been matched;              if want call close function when navigating login view may use "route:login"         */         this.listento( router , "route", this.close );     },     close: function( router, route ) {             /* becaouse route event called every time route changes.                 called when navigating homeview.                 use route argument filter event out              */             if( route != 'home' ){                // close             }     }     .... }); 

Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -