Skip to content
This repository was archived by the owner on Oct 8, 2021. It is now read-only.

Commit 6f3aa9f

Browse files
committed
bind to vmouseup for refresh Fixes #4756
Browsers like chrome provide an up and down arrow for range/number inputs but they don't fire the change even until the control is blurred. Here we bind to the mouseup and check if the value has been altered. If it has we refresh the slider position to reflect the value change.
1 parent a8c84df commit 6f3aa9f

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

js/jquery.mobile.forms.slider.js

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,9 @@ $.widget( "mobile.slider", $.mobile.widget, {
7171

7272
options;
7373

74-
domHandle.setAttribute( 'href', "#" );
74+
this._type = cType;
75+
76+
domHandle.setAttribute( 'href', "#" );
7577
domSlider.setAttribute('role','application');
7678
domSlider.className = ['ui-slider ',selectClass," ui-btn-down-",trackTheme,' ui-btn-corner-all', inlineClass, miniClass].join("");
7779
domHandle.className = 'ui-slider-handle';
@@ -169,6 +171,11 @@ $.widget( "mobile.slider", $.mobile.widget, {
169171
}
170172
});
171173

174+
// it appears the clicking the up and down buttons in chrome on
175+
// range/number inputs doesn't trigger a change until the field is
176+
// blurred. Here we check thif the value has changed and refresh
177+
control.bind( "vmouseup", $.proxy( self._checkedRefresh, self));
178+
172179
slider.bind( "vmousedown", function( event ) {
173180
// NOTE: we don't do this in refresh because we still want to
174181
// support programmatic alteration of disabled inputs
@@ -305,6 +312,18 @@ $.widget( "mobile.slider", $.mobile.widget, {
305312
this.refresh(undefined, undefined, true);
306313
},
307314

315+
_checkedRefresh: function() {
316+
if( this.value != this._value() ){
317+
this.refresh( this._value() );
318+
this.value = this._value();
319+
}
320+
},
321+
322+
_value: function() {
323+
return this._type === "input" ?
324+
parseFloat( this.element.val() ) : this.element[0].selectedIndex;
325+
},
326+
308327
refresh: function( val, isfromControl, preventInputUpdate ) {
309328

310329
// NOTE: we don't return here because we want to support programmatic

0 commit comments

Comments
 (0)