Created
October 17, 2012 20:00
-
-
Save johngag/3907775 to your computer and use it in GitHub Desktop.
tpl loader
This file contains 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
tpl = { | |
templates: {}, | |
loadTemplates: function (names, callback) { | |
var that = this; | |
var loadTemplate = function (index) { | |
var name = names[index]; | |
//console.log('Loading template: ' + name); | |
$.get(APP.WebRoot+'/tpl/' + name + '.html', function (data) { | |
that.templates[name] = data; | |
index++; | |
if (index < names.length) { | |
loadTemplate(index); | |
} else { | |
callback(); | |
} | |
}); | |
} | |
loadTemplate(0); | |
}, | |
get:function (name) { | |
return this.templates[name]; | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment