Opened 13 years ago

Closed 13 years ago

Last modified 10 years ago

#4772 closed bug (duplicate)

"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:


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 ;-(

Change History (3)

comment:1 Changed 13 years ago by machineghost

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.

comment:2 Changed 13 years ago by Scott González

Resolution: duplicate
Status: newclosed

Duplicate of #4751.

comment:3 Changed 10 years ago by Scott González

Milestone: TBD

Milestone TBD deleted

Note: See TracTickets for help on using tickets.