The object is DS.Model:
$E.toString()
> "<reports-dashboard-client-app@model:report::ember596:914fc1b0-b14d-0133-bce2-68a86d03d830>"
The attribute is a Hash:
// app/models/report.js
export default DS.Model.extend({
filters: DS.attr(),
...
});
This is how it looks like now:
$E.get('filters')
> Object {__ember_meta__: Meta}
> __ember_meta__: Meta
> age_groups: (...)
> get age_groups: GETTER_FUNCTION()
> set age_groups: SETTER_FUNCTION(value)
> genders: (...)
> get genders: GETTER_FUNCTION()
> set genders: SETTER_FUNCTION(value)
> __proto__: Object
There is not any change in the Model:
$E.changedAttributes()
> ember$data$lib$system$empty$object$$EmptyObject {}
I modify one of the Hash keys but still not change in the Model:
$E.get('filters.age_groups')
> ["21-30", "31-40"]
$E.set('filters.age_groups', ["21-30"])
> ["21-30"]
$E.changedAttributes()
> ember$data$lib$system$empty$object$$EmptyObject {}
Only if I change the Hash it self I obtain a change in the Model:
$E.set('filters', {})
> Object {}
$E.changedAttributes()
> ember$data$lib$system$empty$object$$EmptyObject {filters: Array[2]}
What is curious is that I can observe the property filters.age_groups
and the Observer is triggered properly when this key has a change.
How can I check if there is any change in the nested keys of DS.Model attribute which is a Hash?
Aucun commentaire:
Enregistrer un commentaire