Backbone.js model.get() returning 'undefined' even though I can see the attributes in console.log

前端 未结 3 705
轻奢々
轻奢々 2020-11-29 10:32

I have a model instance, which I set another model instance on, i.e model.set(\'rsvp\', new App.Rsvp).

When I iterate over the collection to generate th

3条回答
  •  攒了一身酷
    2020-11-29 11:11

    console.log( Object ) can cheat you. It won't show you the state of the Object in the moment of calling console.log.

    Check this jsFiddle and open the console. You see how the console.log shows you the state of the Object at the end of the script and not in the moment of the console.log call.

    For more reliable info call console.log with simpler values.

    (tested is Chrome, Firefox and Safari over OSX)

    Read this for more detailed information: Backbone.js Empty Array Attribute

提交回复
热议问题