2
votes

I try to implement hasOne association in ExtJs 4. I use associationKey to load related model. For example I have Person model. Some people may have spouse, so server side response with nested data like:

...
spouse: {
  id: 5,
  name: ...
  ...
}

Now when I use gettername function like:

var spouse = person.getSpouse()

If person has nested data like in example above it will return Person model object that is spouse of first one. But if there was no nested data, ExtJs try to load it dynamicly requesting the server. I want prevent this requests, can you help me?

1

1 Answers

2
votes

Ok, so I thing I solve this myself. The reason is ExtJs tryed to load nested hasOne related data is because server sended

{
  ...
  spouse_id: null,
  spouse: null,
  ...
}

instead of:

{
  ...
  spouse_id: null,
  spouse: {},
  ...
}