backbone.js - calling Backbone.history.navigate(...) leads to recursion? -


i using bootstrap, backbone, marionette in app require js support. moderately large application many views , sub views. consists of tabbed display, using bootstrap tabs.

in layout view, handling tab shown event , trying tab pane specific rendering below...

var applayoutview = backbone.marionette.layoutview.extend({     el : "body",     regions: {         headerregion: "#ecp_header",         bodyregion: "#ecp_body",         contentregion: "#home"     },      events: {         'shown.bs.tab ul.nav-tabs a': 'ontabshown'     },      ...      ontabshown: function(e) {         var self = this;         console.log("app layout view: 'ontabshown' executing...");         var tabid = $(e.currenttarget).attr('id');          if (tabid === 'home-tab') {             /**  show dashboard (home) view */             require(['user_dashboard_layout'],                      function(userdashboardlayoutview) {              // update url in addressbar, can available in history stack                  backbone.history.navigate('dashboard');              var dblytview = new userdashboardlayoutview();             dblytview.render();             //self.bodyregion.show(dblytview);             //self.contentregion.attachview(dblytview);             });         } else if (tabid == "scheduling-tab") { ... } 

all of working decently, until added line history navigation line shown in above code.

backbone.history.navigate('dashboard'); 

i added app_controller take care of routing. after this, observe strange behavior. see above fn "ontabshown" gets invoked multiple times, seen in browser console window (screenshot attached), whenever perform login/logout on app. enter image description here

btw, in spa (single page app), when user logs in, show dashboard (if user logged in), or show welcome page (if not logged in).

if offending line (history.navigate(...)) present, can see tabshown invoked multiple times, is, each login/logout gets accumulated (some sort of strange recursion, or stack not unwound).

but, if comment out history.navigate line, doesn't perform page refresh after logout.

my basic question is...

  • "does backbone.history.navigate(...) fn play role in actual page navigation/refresh, apart updating history stack?

from documentation, appeared need call bb.h.navigate(...) keep url in addressbar in sync our current state of app. however, experiencing strange behavior?

since app bit complex, may not have provided relevant details soliciting proper answer qn.

may point me in right direction...?


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -