Backbone outputing empty array for collection.models?

假如想象 提交于 2019-12-07 03:53:26
Shaked KO

Are you trying to console.log the collection right after executing the fecth() method or waiting for the callback to be executed by using

apples.on('reset', function(){ console.log(this.models);} ,this); 

?

I just tried this and it worked out for me. Backbone collections have a few underscore methods which work out of the box. Try using toArray to get the apple models in the apples collection.

  apples.toArray()
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!