0

I have a model which has HasMany items in it.

  var Checklist = Backbone.RelationalModel.extend( {                                                                                                                                                                                                                            
      url:  {{ url }}                                                                                                                                        
      relations: [ {                                                                                                                                                                                                                                                            
          type: Backbone.HasMany,                                                                                                                                                                                                                                               
          key: 'items',                                                                                                                                                                                                                                                         
          relatedModel: ChecklistItem,                                                                                                                                                                                                                                          
          collectionType: ChecklistItemCollection,                                                                                                                                                                                                                              
      }],        
  });

I instantiate the model var checklist = new Checklist();

now I initialize Grid and fetch the checklist.

var grid = new Backbone.Grid({columns:columns, collection: checklist.get('items'));
checklist.fetch({reset:true});

I can see in Checklist's parse method that it has retrieved data from the server.
But the grid view doesn't show any data for it.
(When I used plain Backbone.model instead of backbone.RelationalModel, everything worked fine. So I know my setup is correct other than the backbone-relational + backgrid interaction is missing)

I'm new to backbone/javascript/backgrid/... world

I guess I need to hook up some events to make it work.
Please share an insight!

eugene
  • 39,839
  • 68
  • 255
  • 489
  • 1
    Could you link a jsfiddle that shows your problem? I tried to reproduce locally but I couldn't. Everything seemed to work. – gbsice Oct 04 '13 at 15:16
  • 1
    @gbsice: thanks for the input, yes I made it work. I had to convert my json string to javascript object. – eugene Oct 07 '13 at 05:29

0 Answers0