Bug Tracker

Opened 12 years ago

Closed 12 years ago

#2197 closed bug (fixed)

jqueryUI Slider plugin - Multiple handle BUG

Reported by: alexo Owned by: paul
Priority: major Milestone: 1.2.3
Component: ui Version: 1.2.2
Keywords: jquery ui plugin slider Cc: alex.objelean@…
Blocked by: Blocking:

Description

I'm using the demo code of the slider jquery-UI plugin to reproduce the bug. Below is a markup for a slider with multiple handle.

<div id='example3' class='ui-slider-2' style="margin: 40px;">
  <div class='ui-slider-handle'></div>
  <div class='ui-slider-handle' style="left: 188px;"></div>
</div>
<span id="slider-min"></span>
<span id="slider-max"></span>

Here the slider is constructed.

	$('#example3').slider({
          minValue: 0,
          maxValue: 100,
          slide: function(e,ui) {
	    $("#slider-min").text( ui.values[0] );
	    $("#slider-max").text( ui.values[1] );
	  }
        });

When the handler is moved, the span values are updated. The problem is that the second handler have the wrong value (0 instead of maxValue) when the first handler is moved for the first time.

Thank you!

Regards, Alex Objelean.

Change History (2)

comment:1 Changed 12 years ago by alexo

The problem seems to be the initialization of the curValue property in prepareCallbackObj function.

original:

var func = function() {
        var retVal = [];
        for(var i=0;i<cur.interactions.length;i++) {
          retVal.push((cur.interactions[i].curValue || 0)+self.options.minValue);
        }
        return retVal;
      };

Here is my quick&dirty hack for this situation:

prepareCallbackObj: function(self,m) {
      var cur = this;
      var func = function() {
        var retVal = [];
        for(var i=0;i<cur.interactions.length;i++) {
          //myHack
          (i == 1 && cur.interactions[i].curValue == null)
             ? retVal.push(cur.interactions[i].curValue || self.options.maxValue)
             : retVal.push((cur.interactions[i].curValue || 0)+self.options.minValue);
        }
        return retVal;
      };

This is not quite a bug, but it proves that the slider plugin lacks startValues option for multiple handle slider.

Thank you! Regards, Alex Objelean

comment:2 Changed 12 years ago by paul

Resolution: fixed
Status: newclosed

Hi, this is fixed in the new version of slider, which works quite different. To get values for handles, you must call $(el).slider('value', handleIndex) to get the value. Good luck!

Note: See TracTickets for help on using tickets.