Setting a slider's value without triggering the change event
Hey folks,
pretty nasty issue. Every time I've actually worked with our new slider implementation, I had to manually fork it. The reason
is that it's currently not possible (imo) to set the value of a slider without triggering a change event.
Here's the actual issue, as an example I'm using a video playback demo:
1. If you initialize a slider, you most often do it like that:
$('#slider').slider({
change: function() {
//Seek to current value in video
}
});
2. And of course, you also want to update the slider's position based on the current playtime of the video:
$('#slider').slider('value', getCurrentPlayTime());
Here is where it gets problematic. You just want the slider to react in this case, not to be a trigger. Calling the second above
will result in the video seeking and seeking and seeking.
In the old slider implementation (and still in the values method, strangely), We exposed an optional third argument called
noPropagation, that if set to true, simply didn't propagate any events. I strongly suggest we add that one again, unless somebody
finds a better solution to the problem.
<br clear="all">
--
Paul Bakaus
UI Architect
--
<a href="http://paulbakaus.com">http://paulbakaus.com</a>
<a href="http://www.linkedin.com/in/paulbakaus">http://www.linkedin.com/in/paulbakaus</a>