Backbone.js中的模型更新

时间:2014-05-26 10:28:48

标签: javascript backbone.js

我有一个如下的模型。

var FolderModel = Backbone.SP.Item.extend({
    site: 'CapacityManagement',
    list: 'Folder',        
    parse: function(response) {
        var data = {};
        if (response.d) {                
            data.Id = response.d.Id;
            data.Active = response.d.Active;
            data.FolderName = response.d.FolderName;
            data.FolderTypeValue = response.d.FolderTypeValue;
            data.ParentFolderID = response.d.ParentFolderID;                
        }
        else {                
            data.Id = response.Id;
            data.Active = response.Active;
            data.FolderName = response.FolderName;
            data.FolderTypeValue = response.FolderTypeValue;
            data.ParentFolderID = response.ParentFolderID;                                
        }
        return data;
    }       
});

我正在尝试更新模型,但它在解析函数中抛出错误。响应变量返回“undefined”。但代码正在创建和删除。

这就是我更新价值的方式。

folder.save({'FolderName': data.FolderName}, {
            success: function (model,response,options) {},
            error: function (model, response, options) {}
        });

0 个答案:

没有答案