lifegadget/ui-slider

changed event fired before slider value updated

Opened this issue · 4 comments

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???

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.

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

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

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

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 !