vsn4ik / bootstrap-checkbox

A checkbox component based on Bootstrap framework.
https://vsn4ik.github.io/bootstrap-checkbox/
MIT License
213 stars 61 forks source link

disabled still toggable #21

Open gvdhoven opened 8 years ago

gvdhoven commented 8 years ago

It looks like a checkbox, converted to a 'checkboxpicker' can still be changed even though it has been set to readonly. The state of the button changes to dimmed (e.g. disabled) but i can still click on it and it updates the state of the checkbox.

Changing this:

click: function(event) {
  // Strictly event.currentTarget. Fix #19
  var $button = $(event.currentTarget);

  if (!$button.hasClass('active') || this.options.switchAlways) {
    this.change();
  }
}

To this fixed the issue:

click: function(event) {
  // Strictly event.currentTarget. Fix #19
  var $button = $(event.currentTarget);

  if ($button.hasClass('disabled')) {
    return;
  }

  if (!$button.hasClass('active') || this.options.switchAlways) {
    this.change();
  }
},