0

我有这样的视图:

(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我得到以下错误:

Uncaught RangeError: Maximum call stack size exceeded

4

1 回答 1

3

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

于 2012-08-30T09:21:51.300 回答