EML
EML

Reputation: 1025

Input still responding to mouse events after 'disabled' attribute set

Problem: I'm attempting to disable a radio button by using the code below. This always dims the radio button, but it still responds to mouse events (in Opera, the button is actually selected with a tick mark, but the tick is dimmed).

$('input:radio[name=admission1][value=1]').attr("disabled", true);
$('#radioAMethod').buttonset("refresh");
...
$(function(){
   $('#admissionCheckBox1').click(function(){
      ...still executed when button dimmed... why?
   });
});

I've also tried

$('input:radio[name=admission1][value=1]').prop("disabled", true);
$('input:radio[name=admission1][value=1]').attr("disabled", "disabled");

but it makes no difference. How can I disable mouse actions on the button? Thanks.

EDIT

Some html:

<div id="radioAMethod" class="ui-widget-content ui-corner-all effect">
   <h4 class="ui-widget-header ui-corner-all">Admission method</h4>
   <input type ="radio" 
          name ="admission1" 
          id   ="admissionCheckBox0"
          value="0" 
          checked="checked"/>M1<br/>
   <input type ="radio" 
          name ="admission1" 
          id   ="admissionCheckBox1"
          value="1"/>M2<br/>
   <input type ="radio" 
          name ="admission1" 
          id   ="admissionCheckBox2"
          value="other"/>M3<br/>

The code in the click function I showed above does correctly fire when the button is not disabled, and is clicked. Thanks.

EDIT 2

Should have said, but only just realised - this code uses the buttons from http://widowmaker.kiev.ua/checkbox/. If the code should work, then I guess the problem is actually in his JS somewhere.

Upvotes: 0

Views: 467

Answers (1)

Manuel van Rijn
Manuel van Rijn

Reputation: 10315

I think you're doing something wrong

in this example: http://jsfiddle.net/VVP5G/ you'll see a working situation where the disabled input doesn't trigger the click event.

Are you sure the ID correspond to the radio input?

Upvotes: 1

Related Questions