0

I want to /uncheck a checkbox by JS and prevent user to /uncheck it by click.

in normal checkboxes I can use this code:

$('#checkbox').on('click', function(event){
    event.preventDefault();
});

but this code does'nt work for Uniform checkboxes

Ramin Firooz
  • 506
  • 8
  • 25

3 Answers3

2

You can disable the click event:

$('#checkbox').unbind('click');

And then handle it like you want with:

$('#checkbox').prop('checked',true);
$.uniform.update();
Razvan Dumitru
  • 11,815
  • 5
  • 34
  • 54
0

you can use the disable attribute

$('#checkbox').on('click', function(){
    $("#checkbox").attr("disabled", true);
});

that will disable the checkbox once its been clicked leaving it checked

jsfiddle

akaBase
  • 2,178
  • 1
  • 18
  • 31
0

You can use here:

 $('#checkbox').uniform();
 $('#checkbox').unbind('click').bind('click', function(event) {
    event.stopPropagation();
 }); 
Teo Em
  • 21
  • 3