Skip to content

Instantly share code, notes, and snippets.

@eishay
Created March 22, 2012 06:13
Show Gist options
  • Save eishay/2156608 to your computer and use it in GitHub Desktop.
Save eishay/2156608 to your computer and use it in GitHub Desktop.
getResources: function (path, callback) {
$.ajax({
'dataType': 'jsonp text',
'crossDomain': true,
'url': path,
'success': function (data) {
utils.async(function () {
callback(data)
});
},
'error': function (jqXHR, textStatus, errorThrown) {
console.log("Can't compleate request. error: " + textStatus);
throw errorThrown;
}
});
},
injectWidgetTemplate: function (templateName, callback) {
if (Ember.TEMPLATES[templateName]) {
console.log("template " + templateName + " already injected to the page");
return callback(templateName);
}
this.getResources("http://something.myserver.com/template/" + templateName, function (template) {
Ember.TEMPLATES[templateName] = Ember.Handlebars.compile(template);
callback(templateName);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment