Skip to content

Instantly share code, notes, and snippets.

@ovidiuch
Created July 14, 2014 11:56
Show Gist options
  • Save ovidiuch/9b8474a16d01604f5705 to your computer and use it in GitHub Desktop.
Save ovidiuch/9b8474a16d01604f5705 to your computer and use it in GitHub Desktop.
index.html
+ var domContainer = document.getElementById('content');
+ var rootComponent = Boards.render(getFixtureContents(), domContainer);
+ Boards.onRouteChange(function(props) {
+ rootComponent = Boards.render(props, domContainer);
+ });
boards.js
+ onRouteChange: function(callback) {
+ this._onRouteChangeCallback = callback;
+ },
+ changeRoute: function(props) {
+ this._onRouteChangeCallback(props);
}
};
url-proxy.js
var Boards = require('../boards.js'),
Cosmos = require('cosmos-js');
module.exports = {
proxyLink: function(e) {
e.preventDefault();
var props = Cosmos.serialize.getPropsFromQueryString(
e.currentTarget.getAttribute('href'));
Boards.changeRoute(props);
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment