Skip to content

Instantly share code, notes, and snippets.

@johngag
Created October 17, 2012 20:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save johngag/3907775 to your computer and use it in GitHub Desktop.
Save johngag/3907775 to your computer and use it in GitHub Desktop.
tpl loader
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