IE中的Knockoutjs valueHasMutated错误

时间:2012-10-04 18:56:44

标签: internet-explorer knockout.js

我没看到错误在哪里。我有相似页面的另一部分类似的代码与类似的设置在IE中工作正常,但这会引发错误。 我最初尝试只推送每个值,但IE有问题(参见http://www.knockmeout.net/2012/04/knockoutjs-performance-gotcha.html)。

function DocSubType( doc_subtype_id, description ) {
    this.doc_subtype_id = ko.observable( doc_subtype_id );
    this.description = ko.observable( description );
};  
....
docsubtypeModel = [ ], //Where the loaded descriptions are stored. Knockout observers this.

viewDocSubTypeModel = {
    docsubtypes: ko.observableArray(docsubtypeModel),
....
download: function() {
    $.getJSON( DocSubTypesettings.list, function( json ) {
        //Push to the original model and then stated that it has mutated to speed up performance in IE.
        var tmparray = viewDocSubTypeModel.docsubtypes();
        for( i=0; i < json.docsubtypes.length; i++ ) {
            tmp = new DocSubType( json.docsubtypes[i].doc_subtype_id, json.docsubtypes[i].description );
            tmparray.push( tmp );
        }
        viewDocSubTypeModel.docsubtypes.valueHasMutated(); /*ERROR HERE*/        
    });
}

IE8报告“JScript Object expected”knockout-1.2.1.js,第34行字符262.(或者knockout-1.2.1.debug.js,第928行第19行)

1 个答案:

答案 0 :(得分:0)

问题在于我编写了一个导致评估失败的排序助手。