未捕获的类型错误:对象#<对象>没有方法'绑定'-脊梁骨
Uncaught TypeError: Object #<Object> has no method 'bind' - backbone
我得到以下错误:带有主干的Uncaught TypeError: Object #<Object> has no method 'bind'
。
var UpdatingPostView = PostView.extend({
initialize: function (options) {
this.render = _.bind(this.render, this);
this.model.bind('change:title', this.render);
}
});
这是调用函数。
posts.fetch().complete(function() {
var postCollectionView = new PostCollectionView({
collection: posts,
el: $('.posts')[0]
});
postCollectionView.render();
});
这是PostCollectionView
var PostCollectionView = Backbone.View.extend({
initialize: function (post) {
var that = this;
this._postViews = [];
this.collection.each(function() {
that._postViews.push( new UpdatingPostView({
model: post,
tagName: 'div'
}));
});
},
render: function () {
var that = this;
//Clear out this element
$(this.el).empty();
//Render each view and append to parent element
_(this.postViews).each(function (dv) {
$(that.el).append(dv.render().el);
})
}
这里的post
是什么?
initialize: function (post) {
var that = this;
this._postViews = [];
this.collection.each(function() {
that._postViews.push( new UpdatingPostView({
model: post,
当您早些时候实例化它时,您使用。。。
var postCollectionView = new PostCollectionView({
collection: posts,
我不是Backbone方面的专家,但我很确定它不会将一个单独的帖子传递给一个集合的初始化器,该集合会传递一个帖子数组。
我认为你的初始值设定项应该看起来像这样:
initialize: function () {
var that = this;
this._postViews = [];
this.collection.each(function(post) { // <<<<< function(post) is important
that._postViews.push( new UpdatingPostView({
model: post,
相关文章:
- 点击<对象>
- 未能运行构造函数:TypeError:对象#<对象>没有方法'addPlugin'
- JS对象->来自jquery ajax的JSON提交->php迭代
- 如何转换列表<对象>转换为JsonResult
- 为什么不是't html<对象>元素响应鼠标事件
- 如何使用C#列表<对象>在Javascript中
- 使用<对象>用于SVG和HTML中的内联css以编辑填充
- 未捕获的类型错误:对象#<对象>没有方法'绑定'-脊梁骨
- jwplayer转换<对象>到javascript
- AngularJS变量转换为html<对象>属性
- 如何在页面加载到<对象>要素
- 未捕获的类型错误:对象#<对象>没有方法'substr'带标签的标记
- <嵌入>或者<对象>标签视频播放错误处理程序-JavaScript
- 为什么我不能插入<对象/>标记到CKEditor4中
- 更改<对象>.原型的实例方法(通过上下文)
- Ember.js&Q单位:“;类型错误:对象#<对象>没有方法'getHandler'
- Node Selenium WebDriver-目标浏览器必须是字符串,但为<对象>
- <对象>标签
- "对象#<对象>没有方法”;完整日历
- 使用带有<对象>