uploadify +骨干事件问题

时间:2011-07-19 10:37:58

标签: uploadify backbone.js

我有一个多文件uploadify设置:

'onComplete' : function(event, ID, fileObj, response, data) {
    myCollection.add({params parsed from response json});
}

触发(通过this.collection.bind('add',this.add))此集合视图方法:

add: function(obj) {
    var view = new MyModelView({model: obj});
    this.$('.insert-models-here').append(view.render().el);
    return this;
},

new MyModelView来电启动:MyModelView::initialize()来自:

initialize: function() {
    var t = $('#photo-template').html();
    this.template = _.template(t);
    this.model.view = this;
},

每个_.template()都调用__flash__toXML()方法内的所有线程停止的跳转。 结果是我的集合中没有任何模型从任何uploadify事件中添加。

有谁知道为什么以及如何避免这种情况?

1 个答案:

答案 0 :(得分:4)

好的,我找到了解决方案。

问题是在uploadify事件中使用下划线,因此我将下划线_.templates替换为icanhaz并以这种方式重写我的add()集合视图方法以解决任何下划线功能:

    add: function(obj) {
        var view = new MyModelView({model: obj});
        $('.insert-models-here').first().append(view.render().el);
        return this;
    },

希望将来有人会叫我的名字。

相关问题