I am getting some weird behavior when creating models with backbone.js and rails 3.0.7 (and coffeescript).
I create a model with
@model = @collection.create
param : a_param
param : another_param
This saves to rails fine and the return object is what I expect (when I console.log @model it returns a proper looking backbone model with id, cid, attributes...etc).
When I console.log @model.id it returns undefined (Even though it was there in console.log @model).
When I console.log @collection it returns the expected collection, but when I console.log @collection.models it returns an empty array.
When I load the @collection via json in the (rails)page:
( json_from_the_page : #{@collection.to_json} )
@collection = new CollectionName()
@collection.reset options.json_from_the_page
and console.log @collection.models everything works fine so it must be something to do with saving to the server?
Any ideas, or places I should look in the backbone code to further debug?
debugger;
). I have found that console.log frequently displays the future status of variables, and can make debugging difficult. – idbentley