Save several Backbone models at once

后端 未结 3 1941
情歌与酒
情歌与酒 2021-02-06 00:44

I have a Backbone collection with a load of models.

Whenever a specific attribute is set on a model and it is saved, a load of calculations fire off and the UI rerenders

3条回答
  •  别跟我提以往
    2021-02-06 01:45

    You can define a new resource to accomplish this kind of behavior, you can call it MyModelBatch.

    You need to implement a new resource in you server side that is able to digest an Array of models and execute the proper action: CREATE, UPDATE and DESTROY.

    Also you need to implement a Model in your Backbone client side with one attribute which is the Array of Models and a special url that doesn't make use the id.

    About the re-render thing I suggest you to try to have one View by each Model so there will be as much renders as Models have changed but they will be detail re-renders without duplication.

提交回复
热议问题