Posts

Showing posts from March, 2016

RequireJS: Application routing

Find the previous episode here . Checkout the part2.0 branch git checkout -b part2.0 origin/part2.0 In this section we will look into how a routing can be done. For this we are using another lightweight routing framework Page.js .  First install it using bower. bower install visionmedia/page.js We already had added the page in config.js. Now we need to create a router.js which will be in router folder.   define(['page'], function(page) { }); We will create a blank module with loading the page framework. Here we use the Module ID for the module which we defined in config.js. You could use the url also like "bower_components/page/page" But it would be better if a module id us used. NOTE: In requireJS the .JS extension will not be used. Next we will require the router module in app.js. define(['config'], function(config) { "use strict"; require(['router/router']); }); This will load the router module after loading the c