Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Load underscore templates with jQuery $ajax()
window.renderTemplate = function(name, el, json)
var url = '/templates/' + name + '.html';
url: url,
method: 'GET',
async: false,
dataType: 'html',
success: function(data) {
var tmpl = _.template(data);
// 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