jQueryMobile: how to work with slider events?

后端 未结 9 1423
南方客
南方客 2020-12-09 05:32

I\'m testing the slider events in jQueryMobile and I must been missing something.

page code is:

相关标签:
9条回答
  • 2020-12-09 06:02
    <input type="range" id="player-slider" value="25" min="0" max="100"/>
    
    $( "#player-slider" ).bind( "change", function(event, ui) {
        alert ("changed!");
    });
    
    0 讨论(0)
  • 2020-12-09 06:03

    Try this code:

    $( "#slider-1").on('slidestop', function( event ) {
       var slider_value=$("#slider-1").slider().val();
       alert('Value: '+slider_value);
    });
    

    I hope this work for you

    0 讨论(0)
  • 2020-12-09 06:05

    If you want to just catch the event when the slider is released (most probably to optimize ajax requests).

    This worked for me:

    var slider = $('#my_slider');
    //as the answer from @nskeskin you have to remove the type range from your input on the html code
    slider.slider({create:function(){
        //maybe this is too much hacking but until jquery provides a reference to this...
        $(this).next().children('a').bind('vmouseup', yourOnChangeCallback);
    }
    });
    

    Also this prevents that you add events when the control is not yet initialized (or created), so waiting for the create event is a bit more correct I think.

    0 讨论(0)
提交回复
热议问题