我的 jQuery 代码遇到了一个奇怪的问题。我有如下设置:
(function($) {
    var o = $({});
    $.subscribe = function() { o.on.apply(o, arguments); };
    $.publish = function() { o.trigger.apply(o, arguments); };
}(jQuery));
(function($) {
    var CarrierView = {
        subscriptions: function() {
            $.subscribe( 'reporting.carrier.model.changed', this.renderModel );
        },
        renderModel: function( e, data ) {
            var self = CarrierView;
        }
    };
    var CarrierModel = {
        subscriptions: function() {
            $.subscribe( 'reporting.carrier.model.update', this.updateModel );
        },
        updateModel: function( value ) {
            $.getJSON('carriers', function( data ) {
                $.publish( 'reporting.carrier.model.changed', data );
            });
        }
    };
    window.CarrierView = CarrierView.init();
    window.CarrierModel = CarrierModel.init();
})(jQuery);
运行一个非常基本的发布/订阅。我的问题如下:
点击事件触发该CarrierModel.updateModel方法,该方法调用$.getJSON. data返回的是一个,Array[99]然后被publish编辑。当CarrierView.renderModel被调用时,data有 的第一个元素Array[99],一个Array[5]。我做错了什么?如何将整组传递data给视图?