0
변경 사항이 반영되는 동안 높이를 consoling하고 변경 이벤트를 요소에 바인딩합니다. 여전히 콘솔 출력을 얻지 못하고 있습니다 ...백본 - 변화가없는 것 .. 무엇이 잘못 되었나요?
나는 백본에 새로운 것이므로, 실수를 저지른 사람이 있습니까?
var Person = Backbone.Model.extend({
initialize:function(){
// bind is deprecated
this.on('change:height',function(){
console.log(this.get('height'));
});
var getHeight = prompt('provide your height');
this.set({height:getHeight});
},
defaults:{
name:'new Name',
height:'unknown'
}
});
: 당신이 이벤트를 모니터링 할 경우
var Person = Backbone.Model.extend({
initialize:function(){
var getHeight = prompt('provide your height');
this.set({height:getHeight}); //i am changing the height...
this.bind('change:height',function(){
console.log(this.get('height')); //i am not getting any console here...
})
},
defaults:{
name:'new Name',
height:'unknown'
}
});
var person = new Person();