Skip to content

Instantly share code, notes, and snippets.

@dylansm
Created June 23, 2013 06:24
Show Gist options
  • Save dylansm/5844022 to your computer and use it in GitHub Desktop.
Save dylansm/5844022 to your computer and use it in GitHub Desktop.
window.renderTemplate = function(name, el, json)
{
var url = '/templates/' + name + '.html';
$.ajax({
url: url,
method: 'GET',
async: false,
dataType: 'html',
success: function(data) {
var tmpl = _.template(data);
$(el).html(tmpl(json));
}
});
}
// Implementing it in the backbone.
window.MyView = Backbone.View.extend({
el: $('#mainframe'),
render: function(eventName) {
renderTemplate('tmpl_name', this.el, {description: 'This is first template'});
return this;
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment