This is how I take advantage of dojo when developing an application that uses the toolkit.
First, in the past few months most of the applications I developed have has sparse use of JS with one major exception. Each application has an main “application page” where a bulk of the action takes place.
My current project is a large mapping application similar to maps.google.com or maps.live.com. The application instantiates with a large map and a variety of tools that users can use to generate reports based on the underlying map data. There are ancillary pages for help, sitemap, contact, etc that do not require the amount of JS the map interface requires.
I create multiple JavaScript files, one XXXX.js and the other XXXX-app.js. The app.js file is only included on the application specific pages.
Note: during development I will create separate JavaScript files for major functionally but combine them before moving to production.
I try to only include the app.js on the application page.
1:
2: function init() {
3: app_name = new app_name();
4: app_name.postCreate();
5: }
6: dojo.addOnLoad(init);
dojo.declare is my friend..
1: dojo.declare("my_app", null, {
2: _date : '',
3: schedule_success : 'Scheduled',
4: store_dealer : null,
5:
6: constructor: function() {
7: },
8: postCreate: function(){
9: var page_body = dojo.query('body')[0];
10: switch(page_body.id){
11: case 'index':
12: this.index.init();
13: break
14: default:
15: console.log('default');
16: break;
17: }
18: },
19: index: {
20: init: function(){
21: dojo.connect(dojo.byId('dashboard'),'onclick',function(){ dijit.byId('tabs').selectChild('tab_dashboard'); });
22: dojo.connect(dojo.byId('export'),'onclick',function(){ dijit.byId('tabs').selectChild('tab_export'); });
23: }
24: }
25: });
No related posts.