主干对象渲染没有方法应用于 - 与问题绑定 [英] Backbone Object render has no method apply - issue with bind
本文介绍了主干对象渲染没有方法应用于 - 与问题绑定的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
所以我在我的APPVIEW这样
So I'm doing this in my AppView
var flowerModel = new app.DataModel({title: "flower", values: ["tulip","rose","dandelion"], dataToShow:["tulip", "rose", "dandelion"], data: data});
var timelineModel = new app.TimeChartModel({data: flowerModel.getDisplayedData(), titlesToShow: flowerModel.get('dataToShow')});
tableCollection.add(flowerModel);
var timechart = d3.select("body").append("div").attr("class","timechart");
this.centerView = new app.TimeChartView({model: flowerModel, el : timechart});
this.rightView = new app.TableView({model: flowerModel});
在我TimeChartView init方法我做到这一点 -
In my TimeChartView init method I do this-
initialize: function(){
this.model.bind('change','render');
//other, irrelevant things
}
在我flowerModel我有这样的方法,当一个复选框被选中其中工程 -
and in my flowerModel I have this method, which works when a checkbox is ticked -
events: {
'click .data-type' : 'collapseDatum',
'click .show-datum' : 'addDatumToShow',
},
addDatumToShow: function(e){
var test = $(this.$el).find(".datum-list").find(":checked");
newDataToShow = [];
_.each(test, function(value,key,list){
var title = $(value).data("title");
newDataToShow.push(title);
});
this.model.set("dataToShow", newDataToShow);
},
发生在this.model.set('dataToShow',newDataToShow)错误。
The error happens on the this.model.set('dataToShow', newDataToShow).
我真的不知道为什么和如何调试将是有益的任何意见。我不认为我做任何疯狂,或不寻常的位置。
I'm really not sure why and any advice on how to debug would be helpful. I don't think I'm doing anything crazy, or unusual here.
推荐答案
试试这个:
flowerModel.bind('change:dataToShow', function() {
timelineModel.set('titlesToShow', flowerModel.get('dataToShow'));
});
this.model.bind('change', this.render);
这篇关于主干对象渲染没有方法应用于 - 与问题绑定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文