_loadTemplateAsync = function(tmpId, type){
var promise = '', ext = '.js';
if(type == 'html') {
ext = '.html';
}
else if(type == 'js') {
ext = '.js';
}
promise = promises[tmpId] || $.get(_template_dir + tmpId + ext).error(function () {
if(debug && window.console) {
console.log('Cannot load the ' + tmpId + ' view.'); ********************************
}
});
promises[tmpId] = promise;
return promise;
};
return {
// Use jQuery to asynchronously load the template.
loadTemplate : function(templateId, templateType, callback){
var tmpId = templateId.replace("#", "");
var promise = _loadTemplateAsync(tmpId, templateType);
promise.done(function(template){
callback.call(this, $(template));
});
}
};
})();