Search and Top Navigation
#4772 closed bug (duplicate)
Opened August 11, 2009 11:44PM UTC
Closed August 12, 2009 12:41PM UTC
Last modified October 11, 2012 09:15PM UTC
"Prevented" Slides Still Change Values
Reported by: | machineghost | Owned by: | |
---|---|---|---|
Priority: | major | Milestone: | |
Component: | ui.slider | Version: | 1.7.2 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
In theory returning false from a "slide" event handler (in the Slider component) should prevent any values from being changed. However, this is not the case ;-(
The reason this isn't the case is because of the following lines (in "_slide"; don't have exact line numbers because my copy has local changes):
var newValues = this.values();
newValues[index] = newVal;
The problem is that this.values() returns a live reference to the values array (this.options.values), and thus newValues is basically just an alias; if you change it, you change the slider's values ... even if 'this._trigger("slide", event, ...' returns false.
Luckily, this is super simple to fix; just replace the first line with:
var newValues = $.extend([], this.values());
so that it gets a clone of the values rather than a pointer.