Tuesday, February 14, 2012

Get A Model From A Backbone Collection Without Knowing If The Collection Is Loaded | ThoughtStream.new :derick_bailey

Get A Model From A Backbone Collection Without Knowing If The Collection Is Loaded | ThoughtStream.new :derick_bailey: "In working with a client recently, we ran in to a rather sticky situation. We were setting up a route to “persons/:id”, and as you would expect, we wanted to load the person in question and display the details of that person. The trick, though, is that we needed to wait until the persons collection was loaded to be able to retrieve the person from the collection. If we navigate to this route from somewhere else in the application, this isn’t an issue. The persons collection was already loaded and everything goes on normally. If we use a bookmark to get to this url directly, though, then there was no guarantee that the persons collection was loaded because we had not previously run any code to load the collection."

'via Blog this'