Created
October 4, 2013 14:27
-
-
Save fernandofleury/6826824 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// festival.js | |
(function(){ | |
'use strict'; | |
var FestivalView = Backbone.View.extend({ | |
el: '.content', | |
render: function(){ | |
var template = 'text'; | |
this.$el.html(template); | |
} | |
}); | |
var festivalView = new FestivalView(); | |
return festivalView | |
})(); | |
// router.js | |
(function(){ | |
'use strict'; | |
var Router = Backbone.Router.extend({ | |
routes: { | |
"festival": "festival" | |
} | |
}); | |
var router = new Router(); | |
router.on('route:festival', function() { | |
require(['view/festival'], function(festivalView){ | |
festivalView.render(); | |
}); | |
}); | |
Backbone.history.start(); | |
return router | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
main.js - Modulo principal do require
'use strict';
require.config({
shim: {
underscore: {
exports: '_'
},
backbone: {
deps: [
'underscore',
'jquery'
],
exports: 'Backbone'
}
...
},
});
view fica algo assim:
define([
'jquery',
'underscore',
'backbone',
], function ($, _, Backbone, JST, Mustache) {
'use strict';
var FestivalView = Backbone.View.extend({
el: '.content',
});
define([
'jquery',
'backbone'
'view/festival'
], function ($, Backbone, festivalView) {
'use strict';
var Router = Backbone.Router.extend({
routes: {
"festival": "festival"
}
});
});