Skip to content

Instantly share code, notes, and snippets.

@edfuh
Created March 11, 2015 01:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save edfuh/6d82888aaa198cd6f5ab to your computer and use it in GitHub Desktop.
Save edfuh/6d82888aaa198cd6f5ab to your computer and use it in GitHub Desktop.
template loader
// The Template Loader. Used to asynchronously load templates located in separate .html files
window.templateLoader = {
load: function(views, callback) {
var deferreds = [];
$.each(views, function(index, view) {
if (window[view]) {
deferreds.push($.get('tpl/' + view + '.html', function(data) {
window[view].prototype.template = _.template(data);
}, 'html'));
} else {
alert(view + " not found");
}
});
$.when.apply(null, deferreds).done(callback);
}
};
@edfuh
Copy link
Author

edfuh commented Mar 11, 2015

i didn't write this, but it's good

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment