powerange icon indicating copy to clipboard operation
powerange copied to clipboard

How to disable/enable exists slider?

Open DNizovtsev opened this issue 11 years ago • 4 comments

Hi

How to disable/enable exists slider?

Thanks

DNizovtsev avatar Apr 13 '14 19:04 DNizovtsev

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.

abpetkov avatar Apr 13 '14 20:04 abpetkov

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

Thanks.

DNizovtsev avatar Apr 13 '14 21:04 DNizovtsev

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.

abpetkov avatar Apr 14 '14 07:04 abpetkov

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

  • not minified
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");
    }
}
  • minified
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.

rifi avatar Jun 05 '15 15:06 rifi