Skip to content
This repository has been archived by the owner on Apr 30, 2021. It is now read-only.

Commit

Permalink
server routermixin overwrites the navigate function now. yay, navigat…
Browse files Browse the repository at this point in the history
…ion works as expected
  • Loading branch information
Manuel Alabor committed May 12, 2013
1 parent 224d8c0 commit b97332f
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions lib/server/router-mixin.js
Expand Up @@ -85,6 +85,23 @@ function route(routeUri) {
});
}

/** Function: navigate
* Rewrites <Backbone.Router.navigate at http://backbonejs.org/#Router-navigate>
* to replicate its functionality when rendering the application on the server.
*
* Basically the callback for the given routeUri is picked and called.
*
* Parameters:
* (String) routeUri - The URI of the route to navigate to
*
* Returns:
* (Object) the value which the route callbacks returns.
*/
function navigate(routeUri) {
var callback = this[this.routes[routeUri]];
return callback.apply(this, _.values(this.req.query));
}

/** Function: render
* This function initiates the rendering of the passed view. This is done by
* loading the layout template into a cheerio DOM object.
Expand Down Expand Up @@ -147,6 +164,7 @@ function start() {
module.exports = {
preInitialize: preInitialize
, route: route
, navigate: navigate
, render: render
, start: start
};

0 comments on commit b97332f

Please sign in to comment.