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

changed event fired before slider value updated #24

Open
hajjem-ayoub opened this issue Oct 6, 2016 · 4 comments
Open

changed event fired before slider value updated #24

hajjem-ayoub opened this issue Oct 6, 2016 · 4 comments

Comments

@hajjem-ayoub
Copy link

hajjem-ayoub commented Oct 6, 2016

i am doing a post request inside the changed event callback,
my problem is that when i save my model (post it to the backend) it contains an attribute that's binded to the value of the slider, but at that point the slider value is not updated yet it get's updated later on after the changed event is fired, so i am sending an old value of the slider.
exp

onValueChanged(newValue, evt){
this.get("model").save();
}
i can do a simple solution as
onValueChanged(newValue, evt){
this.set("model.bindedValue", newValue);
this.get("model").save();
}
but it make no sense in my head because later on the bindedValue will be updated anyway so why should it be done twice.
should i make a PR or for some reason the changed event should be fired before value is updated???

@yankeeinlondon
Copy link
Member

Can you create a ember-twiddle that shows the problem? I am having a hard time understanding and I think I haven't experienced this before.

@hajjem-ayoub
Copy link
Author

here it is :
https://ember-twiddle.com/2b2d92ca41a78081792dad9e7d9dee2b?openFiles=controllers.application.js%2C

update the value of the slider and check the console log.

@macgyver
Copy link

Noticed this as well - curiously the issue does not seem present in the samples, but maybe they're doing something silly with timeouts..

@HarryLafranc
Copy link

I had the same issue and found something to make it work. Just add an arg to your action and then save it to the model (and send it to your backend etc) :

https://ember-twiddle.com/48621eb153ca73ef075f0b4331f16f0e?openFiles=controllers.application.js%2C

Hope it helps !

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

4 participants