Backbone忽略在保存时发布特定属性?

时间:2015-08-31 15:30:00

标签: javascript backbone.js

我有一个由我创建的contacts数组组成的模型,但是,model.save我不希望这个数组成为保存的一部分。任何人都可以推荐这是如何实现的,只是创建一个关键/值对象我想要POST并将其传递给保存?

模型

{
    "id": 1,
    "name": "Joe Bloggs",
    "position": "Manager",
    "department": "Finance",
    "manages": [
        {
            "id": "FR-1",
            "name": "Jane Doe"
        },
        {
            "id": "FR-23",
            "name": "Simon Wakes"
        }
    ],
    "contacts": [
        {
            "id": "C123",
            "name": "Julian Norris",
            "telephone": "0123456789"
        }
    ]
}

也许我需要做类似的事情:

var newModelData = {
    "name": "Joe Alexander Bloggs",
    "department": "Human Resources"
}

this.model.save(newModelData);

0 个答案:

没有答案