Polling a Collection with Backbone.js

前端 未结 4 461
温柔的废话
温柔的废话 2021-01-30 02:49

I’m trying to keep a Backbone.js Collection up-to-date with what’s happening on the server.

My code is similar to the following:

var Comment = Backbone.M         


        
4条回答
  •  梦如初夏
    2021-01-30 03:24

    Or just use the far simpler addition to backbone's fetch method:

    this.fetch({ update: true });
    

    When the model data returns from the server, the collection will be (efficiently) reset, unless you pass {update: true}, in which case it will use update to (intelligently) merge the fetched models. - Backbone Documentation

    :-)

提交回复
热议问题