Views now load after fetching templates

pull/59/head
Michael Jett 13 years ago
parent 784fd14917
commit 9f979cb742

@ -1,4 +1,3 @@
//$(function () {
var ClientModel = Backbone.Model.extend({ var ClientModel = Backbone.Model.extend({
@ -29,16 +28,9 @@
initialize:function () { initialize:function () {
var self = this; this.template = _.template($('#tmpl-client').html());
this.model.bind('change', this.render, this);
if (!($.isFunction(self.template))) { //this.model.on('change', this.render)
$.get('resources/template/client.html', function (templates) {
$('body').append(templates);
self.template = _.template($('#tmpl-client').html());
});
}
this.model.bind("change", this.render, this);
}, },
render:function (eventName) { render:function (eventName) {
@ -67,13 +59,23 @@
} }
}); });
$(function () {
// load templates and append them to the body
$.get('resources/template/client.html', function (templates) {
$('body').append(templates);
var view = new ClientView({ var view = new ClientView({
el:$('#client-table tbody'), el:$('#client-table tbody'),
model: new ClientModel() model:new ClientModel()
}); });
view.model.set({name:'hello world'}); view.model.set({name:'hello world'});
});
//}); });

Loading…
Cancel
Save