javascript - Backbone/Parse app: links don't work on first load -
i'm creating single-page web app using parse js library, extension of backbone.
my router set follows:
var approuter = parse.router.extend({ routes: { "": "signup", "signup": "signup", "login": "login", "logout": "logout", "dashboard": "dashboard", "history": "history", "account": "account" }, initialize: function(options) { }, login: function() { this.navigateto(new loginview(), false); }, logout: function() { parse.user.logout(); parse.history.navigate("signup", true); }, signup: function() { this.navigateto(new signupview(), false); }, dashboard: function() { this.navigateto(new dashboardview(), true); }, history: function () { this.navigateto(new sentmailview(), true); }, account: function () { this.navigateto(new accountview(), true); }, navigateto: function(view, needssignedin) { if (needssignedin && !parse.user.current()) { parse.history.navigate("signup", true); } else if (!needssignedin && parse.user.current()) { parse.history.navigate("dashboard", true); } else { this.loadview(view); } }, loadview: function(view) { this.view && (this.view.close ? this.view.close() : delete this); this.view = view; } });
at end of main.js
, i'm creating new router, view, , setting pushstate
true:
new approuter; new appview; parse.history.start({pushstate: true});
the problem i'm having (often when first load page of app), none of links work, , refresh page. instance, clicking on link '/history' not load history page, reloads current page. similarly, clicking link bootstrap dropdown menu, supposed trigger js call, reload current page. refreshing browser (via refresh button) fixes this, , links work fine.
any thought why happening?
fixed it. issue beingness caused underlying view wasn't beingness deleted. view had function beingness bound "click a" event -- click on element. same function beingness bound click events on links in dashboard view, did not want.
javascript backbone.js parse.com single-page-application
No comments:
Post a Comment