Skip to content

Instantly share code, notes, and snippets.

@datiecher
Created February 18, 2012 12:35
Show Gist options
  • Save datiecher/1859103 to your computer and use it in GitHub Desktop.
Save datiecher/1859103 to your computer and use it in GitHub Desktop.

Revisions

  1. datiecher created this gist Feb 18, 2012.
    33 changes: 33 additions & 0 deletions fails.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,33 @@
    (function($){
    window.app = {
    init: function() {
    app.router = new app.Router();

    Backbone.history.loadUrl = function(fragmentOverride) {
    var fragment = this.fragment = this.getFragment(fragmentOverride).replace(/^.+\.php\/?/, '');
    console.log('Navigated URL: '+fragment);
    var matched = _.any(this.handlers, function(handler) {
    if (handler.route.test(fragment)) {
    handler.callback(fragment);
    return true;
    }
    });

    return matched;
    };

    Backbone.history.start({ pushState: true });
    }
    };

    app.Router = Backbone.Router.extend({
    routes: {
    '' : 'index'
    },
    index: function() { console.log('index fired') }
    });

    $(function(){
    app.init();
    });
    })(jQuery, undefined);
    20 changes: 20 additions & 0 deletions works.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,20 @@
    (function($){
    window.app = {
    init: function() {
    app.router = new app.Router();

    Backbone.history.start({ pushState: true });
    }
    };

    app.Router = Backbone.Router.extend({
    routes: {
    '' : 'index'
    },
    index: function() { console.log('index fired') }
    });

    $(function(){
    app.init();
    });
    })(jQuery, undefined);