abpetkov / powerange

iOS 7 style range slider
http://abpetkov.github.io/powerange/
423 stars 84 forks source link

How to disable/enable exists slider? #3

Open DNizovtsev opened 10 years ago

DNizovtsev commented 10 years ago

Hi

How to disable/enable exists slider?

Thanks

abpetkov commented 10 years ago

Could you please explain in better english, I'm not sure what your question is?

Disabling a slider is done via the disable property, you can find an example in the demo page.

DNizovtsev commented 10 years ago

I mean how I can disable slider(after some event) then enable slider(after other event)? not just create disabled slider.

Thanks.

abpetkov commented 10 years ago

You can't do that currently, since disabling is handled on creating the slider instance only. I will consider including this in the next version.

rifi commented 9 years ago

I found way. I was added small function in original source(powerange.js)

Powerange.prototype.setDisabled=function(flag){
    if(flag){
        this.options.disable = true;
        this.disable();
    } else {
        this.options.disable = false;
        this.bindEvents();
        this.slider.style.opacity=1;
        classes(this.handle).remove("range-disabled");
    }
}
n.prototype.setDisabled=function(flag){
    if(flag){
        this.options.disable = true,
        this.disable()
    } else {
        this.options.disable = false,
        this.bindEvents(),
        this.slider.style.opacity=1,
        a(this.handle).remove("range-disabled")
    }
}

When you need, just call function setDisabled

var elem = document.querySelector('.js-range');
var init = new Powerange(elem);

init.setDisabled(true);
init.setDisabled(false);

Thank you @abpetkov. I really appreciate your kind library.