Reputation: 1025
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.
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.
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
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