fetching a collection with n elements repeats fetch n times.

30 views
Skip to first unread message

John Stile

unread,
Sep 1, 2016, 8:15:36 PM9/1/16
to backbonejs
My source base is here: https://github.com/johnstile/jobinterface
In js/views/jobs/JobsView.js
  initialize() fetches a jobsCollection,
  but it repeats the fetch equal to the number of elements in the collection.

As my collection grows in elements, the time to complete is growing quickly.

Can someone help find the problem with my code?

Thank you.

John Stile

unread,
Sep 1, 2016, 8:30:04 PM9/1/16
to backbonejs
This is what the browser console shows when I load the jobsView:

init JobsView
JobsView.js:18 instantiate jobsCollection
JobsCollection.js:12 init JobsCollection
JobsView.js:18 listenTo jobsCollection
JobsView.js:18 fetch jobsCollection
JobsView.js:18 child {length: 44, models: Array[44], _byId: Object, _listenId: "l2", _events: Object…}
JobsView.js:18 child {length: 44, models: Array[44], _byId: Object, _listenId: "l2", _events: Object…}
JobsView.js:18 child {length: 44, models: Array[44], _byId: Object, _listenId: "l2", _events: Object…}
JobsView.js:18 child {length: 44, models: Array[44], _byId: Object, _listenId: "l2", _events: Object…}
JobsView.js:18 child {length: 44, models: Array[44], _byId: Object, _listenId: "l2", _events: Object…}
JobsView.js:18 child {length: 44, models: Array[44], _byId: Object, _listenId: "l2", _events: Object…}
JobsView.js:18 child {length: 44, models: Array[44], _byId: Object, _listenId: "l2", _events: Object…}
JobsView.js:18 child {length: 44, models: Array[44], _byId: Object, _listenId: "l2", _events: Object…}
JobsView.js:18 child {length: 44, models: Array[44], _byId: Object, _listenId: "l2", _events: Object…}
JobsView.js:18 child {length: 44, models: Array[44], _byId: Object, _listenId: "l2", _events: Object…}
JobsView.js:18 child {length: 44, models: Array[44], _byId: Object, _listenId: "l2", _events: Object…}
JobsView.js:18 child {length: 44, models: Array[44], _byId: Object, _listenId: "l2", _events: Object…}
JobsView.js:18 child {length: 44, models: Array[44], _byId: Object, _listenId: "l2", _events: Object…}
JobsView.js:18 child {length: 44, models: Array[44], _byId: Object, _listenId: "l2", _events: Object…}
JobsView.js:18 child {length: 44, models: Array[44], _byId: Object, _listenId: "l2", _events: Object…}
JobsView.js:18 child {length: 44, models: Array[44], _byId: Object, _listenId: "l2", _events: Object…}
JobsView.js:18 child {length: 44, models: Array[44], _byId: Object, _listenId: "l2", _events: Object…}
JobsView.js:18 child {length: 44, models: Array[44], _byId: Object, _listenId: "l2", _events: Object…}
JobsView.js:18 child {length: 44, models: Array[44], _byId: Object, _listenId: "l2", _events: Object…}
JobsView.js:18 child {length: 44, models: Array[44], _byId: Object, _listenId: "l2", _events: Object…}
JobsView.js:18 child {length: 44, models: Array[44], _byId: Object, _listenId: "l2", _events: Object…}
JobsView.js:18 child {length: 44, models: Array[44], _byId: Object, _listenId: "l2", _events: Object…}
JobsView.js:18 child {length: 44, models: Array[44], _byId: Object, _listenId: "l2", _events: Object…}
JobsView.js:18 child {length: 44, models: Array[44], _byId: Object, _listenId: "l2", _events: Object…}
JobsView.js:18 child {length: 44, models: Array[44], _byId: Object, _listenId: "l2", _events: Object…}
JobsView.js:18 child {length: 44, models: Array[44], _byId: Object, _listenId: "l2", _events: Object…}
JobsView.js:18 child {length: 44, models: Array[44], _byId: Object, _listenId: "l2", _events: Object…}
JobsView.js:18 child {length: 44, models: Array[44], _byId: Object, _listenId: "l2", _events: Object…}
JobsView.js:18 child {length: 44, models: Array[44], _byId: Object, _listenId: "l2", _events: Object…}
JobsView.js:18 child {length: 44, models: Array[44], _byId: Object, _listenId: "l2", _events: Object…}
JobsView.js:18 child {length: 44, models: Array[44], _byId: Object, _listenId: "l2", _events: Object…}
JobsView.js:18 child {length: 44, models: Array[44], _byId: Object, _listenId: "l2", _events: Object…}
JobsView.js:18 child {length: 44, models: Array[44], _byId: Object, _listenId: "l2", _events: Object…}
JobsView.js:18 child {length: 44, models: Array[44], _byId: Object, _listenId: "l2", _events: Object…}
JobsView.js:18 child {length: 44, models: Array[44], _byId: Object, _listenId: "l2", _events: Object…}
JobsView.js:18 child {length: 44, models: Array[44], _byId: Object, _listenId: "l2", _events: Object…}
JobsView.js:18 child {length: 44, models: Array[44], _byId: Object, _listenId: "l2", _events: Object…}
JobsView.js:18 child {length: 44, models: Array[44], _byId: Object, _listenId: "l2", _events: Object…}
JobsView.js:18 child {length: 44, models: Array[44], _byId: Object, _listenId: "l2", _events: Object…}
JobsView.js:18 child {length: 44, models: Array[44], _byId: Object, _listenId: "l2", _events: Object…}
JobsView.js:18 child {length: 44, models: Array[44], _byId: Object, _listenId: "l2", _events: Object…}
JobsView.js:18 child {length: 44, models: Array[44], _byId: Object, _listenId: "l2", _events: Object…}
JobsView.js:18 child {length: 44, models: Array[44], _byId: Object, _listenId: "l2", _events: Object…}
JobsView.js:18 child {length: 44, models: Array[44], _byId: Object, _listenId: "l2", _events: Object…} 

John Stile

unread,
Sep 2, 2016, 8:00:30 PM9/2/16
to backbonejs
On Thursday, September 1, 2016 at 5:15:36 PM UTC-7, John Stile wrote:
I was wrong this only makes one fetch.
Reply all
Reply to author
Forward
0 new messages