quirkey / sammy

Sammy is a tiny javascript framework built on top of jQuery, It's RESTful Evented Javascript.
http://sammyjs.org
MIT License
2.99k stars 384 forks source link

App.run('#/') doesn't actually changes window hash? #252

Open jumangee opened 8 years ago

jumangee commented 8 years ago

App.run('#/') doesn't actually changes window hash?

Example:

  1. do something with app, hash changes to ..../index.html#/open/
  2. do page reload
  3. 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