Created
March 11, 2015 01:20
-
-
Save edfuh/6d82888aaa198cd6f5ab to your computer and use it in GitHub Desktop.
template loader
This file contains hidden or 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
// 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); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
i didn't write this, but it's good