mirror of
https://github.com/Hopiu/jquery-mobile.git
synced 2026-05-05 21:24:45 +00:00
Fixed bug 676 where the switch toggle (slider) wasn't updating on select change:
https://github.com/jquery/jquery-mobile/issues/labels/5%20-%20Critical#issue/676
This commit is contained in:
parent
7cf5aea8e3
commit
b6ec29a7e5
1 changed files with 8 additions and 6 deletions
|
|
@ -33,7 +33,6 @@ $.widget( "mobile.slider", $.mobile.widget, {
|
|||
min = (cType == 'input') ? parseFloat(control.attr('min')) : 0,
|
||||
max = (cType == 'input') ? parseFloat(control.attr('max')) : control.find('option').length-1,
|
||||
step = window.parseFloat(control.attr('data-step') || 1),
|
||||
|
||||
slider = $('<div class="ui-slider '+ selectClass +' ui-btn-down-'+ trackTheme+' ui-btn-corner-all" role="application"></div>'),
|
||||
handle = $('<a href="#" class="ui-slider-handle"></a>')
|
||||
.appendTo(slider)
|
||||
|
|
@ -74,8 +73,11 @@ $.widget( "mobile.slider", $.mobile.widget, {
|
|||
|
||||
control
|
||||
.addClass((cType == 'input') ? 'ui-slider-input' : 'ui-slider-switch')
|
||||
.keyup(function(){
|
||||
self.refresh( $(this).val() );
|
||||
.change(function(){
|
||||
self.refresh( ((cType == 'input') ? parseFloat(control.val()) : control[0].selectedIndex), true );
|
||||
})
|
||||
.keyup(function(){ // necessary?
|
||||
self.refresh( ((cType == 'input') ? parseFloat(control.val()) : control[0].selectedIndex), true );
|
||||
});
|
||||
|
||||
$(document).bind($.support.touch ? "touchmove" : "mousemove", function(event){
|
||||
|
|
@ -191,7 +193,7 @@ $.widget( "mobile.slider", $.mobile.widget, {
|
|||
this.refresh();
|
||||
},
|
||||
|
||||
refresh: function(val){
|
||||
refresh: function(val, isfromControl){
|
||||
if ( this.options.disabled ) { return; }
|
||||
|
||||
var control = this.element, percent,
|
||||
|
|
@ -211,7 +213,7 @@ $.widget( "mobile.slider", $.mobile.widget, {
|
|||
percent = Math.round( ((data.pageX - this.slider.offset().left) / this.slider.width() ) * 100 );
|
||||
} else {
|
||||
if ( val == null ) {
|
||||
val = (cType === "input") ? parseFloat(control.val()) : control[ 0 ].selectedIndex;
|
||||
val = (cType === "input") ? parseFloat(control.val()) : control[0].selectedIndex;
|
||||
}
|
||||
percent = (parseFloat(val) - min) / (max - min) * 100;
|
||||
}
|
||||
|
|
@ -252,7 +254,7 @@ $.widget( "mobile.slider", $.mobile.widget, {
|
|||
} else {
|
||||
control[ 0 ].selectedIndex = newval;
|
||||
}
|
||||
control.trigger("change");
|
||||
if (!isfromControl) { control.trigger("change"); }
|
||||
},
|
||||
|
||||
enable: function(){
|
||||
|
|
|
|||
Loading…
Reference in a new issue