Answer the question
In order to leave comments, you need to log in
How to get the value of the name attribute?
var NewUserView =Backbone.View.extend({
initialize: function() {
this.model = new NewUserModel();
console.log ('hello');
},
el: 'body',
events: {
"focusout .textField" : "setValue"
},
setValue: function(){
_.each(this.el, function(){
if (this.attr('name') == this.model.attributes('attrName')) {
this.model.set({'attrName':'.val()'})
}
}, this)
}
});
var userView = new NewUserView();
Answer the question
In order to leave comments, you need to log in
Strange code. Why do _.each on a DOM element? Why are you accessing model attributes directly?
var input = $(evt.target);
if (input.attr('name') === this.model.get('attrName')) {
this.model.set('attrName', input.val())
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question