현재 Backbone.js를 배우고 이상한 문제가 있습니다. 이것이 이것을 구현하는 적절한 방법인지 확실하지 않습니다. 백본보기 및 모델에서 jQuery UI Slider를 래핑하려고합니다. 그러나 슬라이더의 슬라이드 메서드 내에서 모델의 값에 액세스 할 수 없습니다. 어떤 도움을 주셔서 감사합니다. 여기 내 코드 :Backbone.js에서 모델에 액세스 할 수 없습니다.
var SliderView = Backbone.View.extend({
initialize: function(){
console.log("Creating the slider view...");
_.bindAll(this, 'render');
this.render();
},
render : function(){
console.log("Rendering the slider...");
$("#slider-vertical").slider({
orientation: "vertical",
animate: true,
range: "min",
min: 0,
max: 50,
value: this.model.get('value'),
disabled: this.model.get('disabled'),
animate_if_programmed: true,
slide: function(ui) {
console.log(model);
this.model.set('value', ui.value);
},
stop: function() {
this.check_bounds();
}
});
console.log("Finished rendering...");
}
})
var SliderModel = Backbone.Model.extend({
initialize : function(args) {
console.log("Creating the slider model...");
},
defaults : {
disabled : false,
value: 8,
position: 0
}
});
$(function(){
var sliderModel = new SliderModel();
var slider = new SliderView({ el: $("#slider-vertical"), model: sliderModel });
})
고마워!