]> source.dussan.org Git - jquery-ui.git/commitdiff
Slider: fixed change event to be triggered by keyup and value and values option sette...
authorRichard Worth <rdworth@gmail.com>
Wed, 17 Mar 2010 17:39:29 +0000 (17:39 +0000)
committerRichard Worth <rdworth@gmail.com>
Wed, 17 Mar 2010 17:39:29 +0000 (17:39 +0000)
tests/unit/slider/slider_events.js
ui/jquery.ui.slider.js

index dd68a74b6d8020d66c0143ce49eae2b8009e4e4d..fb9af8155ef03e134720248e1c1e90f23a4c0bb1 100644 (file)
@@ -20,7 +20,7 @@ test( "slide", function() {
 // value (even if same as previous value), via mouse(mouseup) or keyboard(keyup)
 // or value method/option"
 test( "change", function() {
-       expect(7);
+       expect(8);
        
        var handle;
        // Test mouseup at end of handle slide (mouse)
@@ -48,7 +48,7 @@ test( "change", function() {
        el.find( ".ui-slider-handle" ).eq( 0 )
                .simulate( "keydown", { keyCode: $.ui.keyCode.LEFT } )
                .simulate( "keypress", { keyCode: $.ui.keyCode.LEFT } )
-               .simulate( "keyup", { charCode: $.ui.keyCode.LEFT } );
+               .simulate( "keyup", { keyCode: $.ui.keyCode.LEFT } );
 
        reset();
        // Test value method
index be90cdb81857745120c74cb77cf8e6cc43b037ae..c392facd79b753bfdc476366f9f9996f934bca99 100644 (file)
@@ -193,9 +193,9 @@ $.widget("ui.slider", $.ui.mouse, {
                        var index = $(this).data("index.ui-slider-handle");
 
                        if (self._keySliding) {
+                               self._keySliding = false;
                                self._stop(event, index);
                                self._change(event, index);
-                               self._keySliding = false;
                                $(this).removeClass("ui-state-active");
                        }
 
@@ -479,6 +479,12 @@ $.widget("ui.slider", $.ui.mouse, {
        },
 
        _setOption: function(key, value) {
+               
+               var i,
+                       valsLength = 0;
+               if ( jQuery.isArray(this.options.values) ) {
+                       valsLength = this.options.values.length;
+               };
 
                $.Widget.prototype._setOption.apply(this, arguments);
 
@@ -505,11 +511,15 @@ $.widget("ui.slider", $.ui.mouse, {
                        case 'value':
                                this._animateOff = true;
                                this._refreshValue();
+                               this._change(null, 0);
                                this._animateOff = false;
                                break;
                        case 'values':
                                this._animateOff = true;
                                this._refreshValue();
+                               for (i = 0; i < valsLength; i++) {
+                                       this._change(null, i);
+                               }
                                this._animateOff = false;
                                break;
                }