remove arrive dependency

This commit is contained in:
s2
2019-04-14 22:14:12 +02:00
parent 52bea6d10d
commit 9d3cd7ec4f
6 changed files with 27 additions and 21 deletions

View File

@@ -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();
})();