Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/backbone.js/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/performance/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Backbone.js 使用主干删除视图_Backbone.js - Fatal编程技术网

Backbone.js 使用主干删除视图

Backbone.js 使用主干删除视图,backbone.js,Backbone.js,我有这样的看法: (function(views) { views.FilterView = Backbone.View.extend({ tagName: 'div', events: { 'click a.remove': 'remove' }, template: _.template($("#filterViewTemplate").html()), render: func

我有这样的看法:

(function(views) {
    views.FilterView = Backbone.View.extend({
        tagName: 'div',
        events: {
            'click a.remove': 'remove'
        },
        template: _.template($("#filterViewTemplate").html()),

        render: function() {
            this.$el.html(this.template());
            return this;
        },
        remove: function (e) {
            this.remove();
            this.unbind();
        }
    });
})(app.views);
它的模板是:

<script type="text/html" id="filterViewTemplate">
    <select class="filterByOption">
        <option value="Account">Account</option>
        <option value="Owner">Owner</option>
    </select>

    <span class="cell sort">
        <input class="filterString cell" type="text" />
    </span>
    <a href="#" class="btn small remove">Remove</a>
</script>

账户
所有者
但是当我点击
Remove
时,我得到以下错误:


未捕获范围错误:超过了最大调用堆栈大小

这是因为在
remove
方法中调用
this.remove()
哪个调用
remove()
哪个调用
remove()
哪个调用
remove()这是因为在你的
remove
方法中,你调用
this.remove()
哪个调用
remove()
哪个调用
remove()
哪个调用
remove()

你可以尝试
this.constructor.\uu super\uuu.remove.call(this)
。一个装饰性的技巧,但是我想命名删除视图和事件的函数
cleanup
。就我的2个世纪,你可以尝试
this.constructor.\uu super\uuuu.remove.call(this)
。这是一个装饰性的提示,但我想给移除视图和事件的函数命名
cleanup
。只要我的2美分