0

为什么事件“更改”适用于模型评论 1?怎么修?如果我删除行('comment':[]),事件'change'不起作用。我明白这是因为我使用数组,但我需要使用它,但我没有事件,如果他没有任何变化。谢谢/


创建新集合

var commentCollection = new VPRS.Comment.CommentCollection([
  {
    "id": "comment1",
    "questionId": "post1",
    "name": "Alex",
    "text": "text 1",
    "comment":[]
  },
  {
    "id": "comment2",
    "questionId": "post1",
    "name": "Alex",
    "text": "Text2"
  }
]);


----------

    json = [
      {
        "id": "comment1",
        "questionId": "post1",
        "name": "Alex",
        "text": "text 1",
        "comment":[]
      },
      {
        "id": "comment2",
        "questionId": "post1",
        "name": "Alex",
        "text": "Text2"
     }]

--------------
wallItemCollection.on('change', function (model) {
  console.log('model change')
}
 ------------
wallItemCollection.fetch({
  update: true,
  merge: true,
  success: function () {
    console.log('fetch compleate')
  }
});
4

0 回答 0