Created
June 23, 2013 06:24
-
-
Save dylansm/5844022 to your computer and use it in GitHub Desktop.
This file contains 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
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