3

I'm new to backbone. I have rails3 app. These are my backbone models:

class AppName.Models.Order extends Backbone.RelationalModel
  paramRoot: 'order'

  relations: [
    type: Backbone.HasMany
    key: 'order_services'
    relatedModel: 'AppName.Models.OrderService'
    collectionType: 'AppName.Collections.OrderServicesCollection'
    includeInJSON: false
    reverseRelation:
      key: 'order_id',
      includeInJSON: 'id'
  ]

class AppName.Models.OrderService extends Backbone.RelationalModel
  paramRoot: 'order_service'

I have new order model which is not saved at server yet. How can I create new order_service as a child of that order, so I could access order with order_service.get('order')?

I need to build order step by step: add order_services, add other models, and then save the order. Is that possible to store locally not saved order with its order_services (which also have not saved children of other models) and then save all this stuff at server?

4

0 回答 0