下划线'后'功能

时间:2013-11-05 15:16:33

标签: backbone.js underscore.js

我的代码与此相似

(function(exports, $, Backbone, document){
    "use strict";

    var modals = {
        "Alerts.alert_delete" : (function() {
            var self = this;    
            return {
                template : {
                    count : this.collection.length,
                    models : this.collection.models
                },
                events : {
                    "click .confirm" : function(event) {
                        event.preventDefault();
                        var modal = this,
                            finished = _.after(modal.collection.length, self.reDraw);

                        // Models are succesfully delete, but finished is not completed 
                        this.collection.each(function(model) {
                            modal.collection.sync('delete', model, { success : finished });
                        });
                    }
                }
            };
        })
    };

    exports.app.modal = function(name, context) {
        return modals[name].call(context);
    };
}(this, jQuery, Backbone, document));

请忽略抽象,这是为了让我对所有模态使用一个通用视图,同时保持抽象的独特逻辑。我不知道为什么_.after函数在调用正确的次数时没有完成。此实例中的self是对父视图的引用。

有人可以为我阐明这个吗?

0 个答案:

没有答案