Issue with Backbone fetching data only for the first model in the collection.
@leadgen_forms = new app.collections.LeadgenForms [],
{ event_provider_id: @event_provider_id }
@leadgen_forms.fetch
success: _.bind ((collection, response) ->
debugger
Upon inspecting the collection from the success function:
https://i.sstatic.net/Qg3FF.png
The screenshot above indicates a length of 11 but only one model is present. It seems like Backbone treats models as duplicates if they don't have unique ids. However, reviewing the data from the JSON service confirms that all ids are indeed unique and everything else appears to be correct:
https://i.sstatic.net/1yYE4.png
Details from the model:
window.app.models.LeadgenForm = Backbone.Model.extend
initialize: (model, options) ->
@event_provider_id = options.event_provider_id
@id = options.id
url: ->
if @id
'/event_providers/' + @event_provider_id + '/leadgen_forms/' + @id
else
'/event_providers/' + @event_provider_id + '/leadgen_forms'
window.app.collections.LeadgenForms = Backbone.Collection.extend
model: window.app.models.LeadgenForm
initialize: (collection, options) ->
@event_provider_id = options.event_provider_id
parse: (response) ->
debugger
return response
url: ->
'/event_providers/' + @event_provider_id + '/leadgen_forms'