Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updating a fragment's attribute in a form doesn't set the fragment as dirty #340

Open
Leooo opened this issue Oct 18, 2019 · 3 comments
Open

Comments

@Leooo
Copy link

Leooo commented Oct 18, 2019

Ember | 3.4.8
Ember Data | 3.5.2
jQuery | 2.1.4
Model Fragments | 4.0.0

//models/appointment.js
export default Model.extend({
  telephoneNumber: MF.fragment('phone-type')
});
//models/phone-type.js
export default MF.Fragment.extend({
  type: DS.attr('string'),
  number: DS.attr('string')
});

(existing appointment)

appointment.changedAttributes(); // {}
appointment.set('telephoneNumber.number', '07777777777');
appointment.changedAttributes(); // {}
appointment.telephoneNumber.changedAttributes(); // {number: Array(2)}

So appointment.changedAttributes() is not updated, which prevents the telephoneNumber to be serialized (at least when using ember-data-change-tracker, but I think it's an ember-data-model-fragments problem).

Anyone else seeing this? Can try to create a jsfiddle or test if needed.

@Leooo
Copy link
Author

Leooo commented Oct 18, 2019

someone needs to add https://ember-twiddle.com/ on top of SEO for "Ember jsfiddle"

@Leooo
Copy link
Author

Leooo commented Oct 18, 2019

so on https://ember-twiddle.com/499e21ed033ff8270dcd966904b02c4c?openFiles=routes.application.js%2C, things work.. Can't reproduce on ember-twiddle then :(

@hew
Copy link

hew commented May 19, 2023

Not ideal, but you can manually set it dirty:

send('becomeDirty');

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants