sammy
sammy copied to clipboard
App.run('#/') doesn't actually changes window hash?
App.run('#/') doesn't actually changes window hash?
Example:
- do something with app, hash changes to ..../index.html#/open/
- do page reload
- hash doesn't changes and app open route #/open/, but should - #/
require(['jquery','sammy','mainapp','bootstrap','mustache_plugin'], function($, Sammy, App) {
$(document).ready(function() {
App.init();
App.log('Start');
App.run('#/');
});
});
...
app = Sammy('#container', function theCharsheetApp() {
var localGameDefs = ['fabled']; // should be stored in db
var currentGame = 'fabled';
var gameinfo = null;
var self = this;
var currentPage = null;
var locale = [];
var templates = {};
this.init = function() {
//this.setLocation('#/');
this.use('Mustache','ms.html');
for (var path in defaultControllers) {
if (!defaultControllers.hasOwnProperty(path)) continue;
(function(p, n) {
self.log('app::bind ' + p + ' to ' + n);
self.get(p, function() {
var etx = this;
self.log('load controller ' + n);
require(['app/controller/' + n], function(page) {
self.log(page);
self.log('app::controller ' + n + ' open');
if (currentPage && currentPage.hide) {
currentPage.hide(etx);
}
return;
page.show.apply(etx);
currentPage = page;
});
})
})(path, defaultControllers[path]);
}
}
...
Log: app::bind #/ to default app::bind #/setup to setup app::bind #/gamelist to gamelist app::bind #/loadgame to loadgame app::bind #/cs/:num/:group to charsheet app::bind #/open/:name to opengame Start load controller opengame app::controller opengame open