Skip to content

Commit

Permalink
Merge pull request #118 from KleeGroup/route
Browse files Browse the repository at this point in the history
Route
  • Loading branch information
pierr committed Jun 3, 2015
2 parents 771719c + 90c0519 commit 5ecb383
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 3 deletions.
1 change: 1 addition & 0 deletions application/action-builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ module.exports = function(config){
//Exposes a function consumes by the compoennt.
return function(criteria){
preServiceCall(config);
//todo: add middleware see slack for more informations
return config.service(criteria).then(function(jsonData){
postServiceCall(config, jsonData);
}, function actionError(err){
Expand Down
4 changes: 3 additions & 1 deletion application/render.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,12 @@ module.exports = function renderComponent(component, selector, options){
options = options || {};
// Clear a potential previously mounted component
clearComponent(selector);
let targetDOMContainer = document.querySelector(selector);
if(!targetDOMContainer){throw new Error(`You are trying to render a component in a DOM element which is not existing, your selector is ${selector}`); }
// Render the component
var mountedComponent = React.render(
React.createElement(component, options.props, options.data),
document.querySelector(selector)
targetDOMContainer
);
//Save the fact that a component is mounted.
mountedComponents[selector] = mountedComponent;
Expand Down
3 changes: 2 additions & 1 deletion gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,8 @@ gulp.task('browserify', function(){
.transform(
{global:true},
literalify.configure({
react: 'window.React'
react: 'window.React',
backbone: 'window.Backbone'
}))
.transform(babelify)
.bundle()
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"test": "test"
},
"dependencies": {
"backbone": "^1.2.0",
"flux": "^2.0.3",
"immutable": "^3.7.3",
"keymirror": "^0.1.1",
Expand Down
11 changes: 10 additions & 1 deletion router/index.js
Original file line number Diff line number Diff line change
@@ -1 +1,10 @@
module.exports = {};
var render = require('../application/render');
var Backbone = require('backbone');
module.exports = Backbone.Router.extend({
/**
* Render the compoennt into the page content.
*/
_pageContent(component, options){
return render(component, '[data-focus="page-content"]', options);
}
});

0 comments on commit 5ecb383

Please sign in to comment.