Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to disable slider in bootstrap-slider.js?

is there any solution to stop dragging when click on the button.

the documentation do not give proper description

http://www.eyecon.ro/bootstrap-slider/

$("#stopDrag").click(function(){

});

DEMO http://jsfiddle.net/sweetmaanu/npGw2/

like image 386
Mo. Avatar asked Sep 26 '13 12:09

Mo.


People also ask

How do I disable slider?

Disabling a slider is identical to disabling a checkbox or textarea; add the disabled attribute. A disabled slider can't be changed by user interaction (sliding, clicking or touching), but its value can still be changed using the . set() method. CSS can be used to show the disabled state.

How do you stop a carousel slider in bootstrap?

carousel({ interval: false, }); That will make the auto sliding stop because there no Milliseconds added and will never slider next.

How do you stop a carousel slider?

Use the [interval]="'0'" input. This will disable the auto-sliding feature. Here's the link to the Carousel Documentation.

What is a bootstrap slider?

Bootstrap slider is an interactive component that lets the user swiftly slide through possible values spread over a desired range. Multi-range slider. Note: You can also see multi-range sliders, but remember, that they do not work with this plugin.


Video Answer


1 Answers

Extend the slider plugin with a enable and disable function like:

<script src="/slider/js/bootstrap-slider.js"></script>
<script>
$.fn.slider.Constructor.prototype.disable = function () {
    this.picker.off();
}
$.fn.slider.Constructor.prototype.enable = function () {
    if (this.touchCapable) {
        // Touch: Bind touch events:
        this.picker.on({
            touchstart: $.proxy(this.mousedown, this)
        });
    } else {
        this.picker.on({
            mousedown: $.proxy(this.mousedown, this)
        });
    }
}
</script>

Demo: http://bootply.com/83445

Example html:

<div class="container" style="background-color:darkblue;">
<br>
<input id="slide" type="text" class="span2" value="" data-slider-min="-20" data-slider-max="20" data-slider-step="1" data-slider-value="-14" data-slider-orientation="vertical" data-slider-selection="after">

<button id="enable">Enable</button>
<button id="disable">Disable</button>
</div>

example javascript:

$('#slide').slider();

$('#enable').click(function(){ $('#slide').slider('enable') });
$('#disable').click(function(){ $('#slide').slider('disable') });
like image 95
Bass Jobsen Avatar answered Oct 23 '22 10:10

Bass Jobsen