0

我在 Zurb Foundation Reveal (Modal) 部分打开一个主干视图。

this.$('#ChangeIconModal').html( this.editIconView.render().el );

这第一次工作正常。但是,如果我关闭它(通过单击它或通过调用$('#ChangeIconModal').foundation('reveal', 'close')),我设置的单击事件将不再触发。

这是我设置点击事件的方式:

events: { 'click button.finish': 'finish', 'click a.close-reveal-modal': 'close' }

而且,无论关闭是如何发生的,我都会在完成后删除 Backbone 视图:

this.remove();

我正在做的事情似乎有什么明显的错误吗?

PS - 我是整个 Backbone/Zurb 世界的新手,所以请耐心等待。如果您需要更多信息,我很乐意提供,我只是不知道该提供什么。

4

1 回答 1

1

啊,我想通了。这就是我所做的,以防其他人遇到同样的问题。

以下是我之前的看法:

initialize: function() {
    // Other initialize code here...
    this.editIconView = new IconEditView({ model: this.model });
}

iconEdit: function() {
    this.$('#SubtabEditModal').html( this.editIconView.render().el );
}

但是,因为我remove后来调用了它,所以对的引用editIconView不再有效。

我不得不将我的代码更改为更像这样:

initialize: function() {
    // Other initialize code here...
}

iconEdit: function() {
    this.editIconView = new IconEditView({ model: this.model });
    this.$('#SubtabEditModal').html( this.editIconView.render().el );
}

它现在似乎正在工作。如果不清楚,请发表评论,我会尽力提供帮助。

于 2013-09-09T18:35:29.503 回答