remove arrive dependency
This commit is contained in:
17
js/index.js
17
js/index.js
@@ -16,7 +16,15 @@
|
||||
MyApp.renderShell = function() {
|
||||
document.title = i18next.t('vanillaJS');
|
||||
|
||||
$('.js-main-content').html(ejs.rr('/templates/main.ejs'));
|
||||
var d = $.Deferred();
|
||||
|
||||
//preload this template, so we can be sure the dom in rendered when we resolve
|
||||
ejs.preloadTemplate('/templates/main.ejs')
|
||||
.then(function(templateUrl) {
|
||||
$('.js-main-content').html(ejs.rr(templateUrl));
|
||||
d.resolve();
|
||||
});
|
||||
return d;
|
||||
};
|
||||
|
||||
MyApp.renderHomePage = function() {
|
||||
@@ -77,8 +85,9 @@
|
||||
}
|
||||
});
|
||||
|
||||
// when main content is rendered, set up routing so the app starts up
|
||||
$(document).arrive('.js-page-container', {existing: true, onceOnly: true}, function() {
|
||||
// render main shell
|
||||
MyApp.renderShell()
|
||||
.then(function() {
|
||||
//setup routing
|
||||
page('/', MyApp.renderHomePage);
|
||||
page('/about', MyApp.renderAboutPage);
|
||||
@@ -88,6 +97,4 @@
|
||||
hashbang: true
|
||||
});
|
||||
});
|
||||
|
||||
MyApp.renderShell();
|
||||
})();
|
||||
|
Reference in New Issue
Block a user