#27 new
Paul butler

slider.setValue second argument when slider is active

Reported by Paul butler | June 17th, 2008 @ 07:56 PM

When calling slider.setValue and passing both arguments, if the second argument is 0 and the active handle is not 0, the active handle will be moved instead of the 0th handle.

The bug is in this code:

handleIdx = handleIdx || this.activeHandleIdx || 0;

If handleIdx = 0, it evaluates to false and is replaced with this.activeHandleIdx.

I have attached a git diff which fixes the bug by explicitly testing whether handleIdx is set. The diff also patches the slider unit test to demonstrate the bug.

(By the way, I'm new to this, so please let me know if there is a preferred way to submit this.)

Comments and changes to this ticket

  • AJ

    AJ December 2nd, 2008 @ 06:17 AM

    • Tag set to controls, scriptaculous, slider

    Hi Paul, I know this bug has been around forever, but I'd just like to second the need for a fix for this. My workaround for this bug is to set slider.active = false manually before invoking setValue. (I use the googleapi-hosted scriptaculous files, so I cannot modify the source directly.)

    I'd love to see the simple fix you suggested be incorporated into a future release.

    AJ

  • Fritz

    Fritz March 5th, 2009 @ 08:44 PM

    ...and I'd like to third it. :-)

    In my case setting slider.active = false doesn't seem to help, so I'm having to patch my version of slider.js

  • Lorp

    Lorp March 4th, 2010 @ 04:33 AM

    Yeah, shame this simple bug can't get fixed! Took me a while to work out what was going on...

    The solution I use is to make the handle at index 0 invisible using CSS, and basically ignore it from then on. So for a 3-handle slider you'd create 4 handles, thus:

    <div class="handle" style="visibility:hidden;"></div>
    <div class="handle" style="background-color:red;"></div>
    <div class="handle" style="background-color:green;"></div>
    <div class="handle" style="background-color:blue;"></div>
    

    Then when you create your SliderHandle, give handle #0 an arbitrary initial value, 0 in this case:

    new Control.Slider(rgb_slider.select('.handle'), rgb_slider, {

      ...
      sliderValue: [0, 45, 46, 244],
      ...
    

    Works well for me. The above code is adapted from:

    http://wiki.github.com/madrobby/scriptaculous/slider

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

script.aculo.us is an open-source JavaScript framework for visual effects and interface behaviours.
<br/><b>Source available from github</b>
The Git repository resides at:
<a href="http://github.com/madrobby/scriptaculous">http://github.com/madrobby/scriptaculous</a>
<br/>Check out the current development trunk with:
<code>git clone git://github.com/madrobby/scriptaculous.git</code>
<br/>As <b>script.aculo.us 1.xx is feature-frozen</b>, this development trunk is for <b>bugfixes only</b>.
<br/>New development should happen only for
<b>script.aculo.us 2</b>.
<br/><b>Creating a bug report</b>
When creating a bug report, be sure to include as much relevant information as possible. Post a an example that shows off the problem. Preferably, <b>alter the unit tests</b> and show through either changed or added tests how the expected behavior is not occuring.

People watching this ticket

Attachments

Referenced by

Pages