Answer the question
In order to leave comments, you need to log in
How to render Backbone-View so that a new element is created, not text?
var Person = Backbone.Model.extend({})
var PersonView = Backbone.View.extend({
el:'body',
template: _.template($('#userTemplate').html() ),
initialize: function(){
this.render();
console.log(this)
},
render:function(){
console.log(this.model.toJSON() )
this.$el.append( this.template(this.model.toJSON() ))
return this
}
})
function save(){
var name = $('#name').val()
var newPerson = new Person({name: name})
var personView = new PersonView({model: newPerson});
personView.el
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question