How to clone a backbone collection

前端 未结 4 549
遥遥无期
遥遥无期 2021-02-05 00:58

Is there a way to easily clone Backbone Collection? I wonder why there is no build in method like for models. My problem is that I have a model holding a collection of childs. W

4条回答
  •  情深已故
    2021-02-05 01:53

    Simplest way:

    var cloned = new Backbone.Collection(original.toJSON());
    

    where original is the collection to clone.

    Could always then extend Backbone's Collection to add clone support w or w/o inheritance support.

提交回复
热议问题