0

I'm using this for a function and it is showing up in my console as disabled, but I can still select the button. Any idea what I'm doing wrong?

Here is the line in the function (the rest of which is working):

$("#paycd li#li_6hr input[name=radio6]:radio").attr('disabled',true);

the slim (an html generator) code:

li#li_48hr data-turnAroundTime="6"
      input.updateTurnaround id='updateTarget_6' type='radio' style='display:none' name="radio6"

And my console output:

<input class="updateTurnaround" id="updateTarget_6" name="radio6" style="display:none" type="radio" disabled="disabled">
  • If you're using an **ID** for the `radio` button, why not just use `$("#updateTarget_6").prop('disabled',true);`? – Vucko Jul 15 '13 at 20:09
  • Know what's funny? Disabling an element with vanilla JavaScript is shorter: `element.disabled = true`. – cimmanon Jul 15 '13 at 20:20
  • Please can you add a fiddle –  Jul 15 '13 at 20:21
  • Vucko, I tried that, but it didn't even show up in the console. Cinnamon, I'll give that a shot. – user2574616 Jul 15 '13 at 20:22
  • Cinnamon, it didn't work in that form. Is this the syntax you would use? $('input#updateTarget_6').disabled = true; or $('input#updateTarget_6').element.disabled = true; – user2574616 Jul 15 '13 at 20:30
  • unfortunately, jsfiddle doesn't parse slim. – user2574616 Jul 15 '13 at 20:36
  • I don't use jQuery. This is simple basic JavaScript. *Element* just refers to the element in question (eg. `document.getElementById('foo').disabled = true`). – cimmanon Jul 15 '13 at 20:37

1 Answers1

0

Your issue may have to do with attr() try using prop(). Please reference link below.

Link

$('#updateTarget_6').prop("disabled", true);

or

$('#updateTarget_6')[0].disabled = true;
Community
  • 1
  • 1
Tomas Santos
  • 560
  • 4
  • 12
  • Nope. Still can be checked but shows as disabled in the console. – user2574616 Jul 15 '13 at 20:19
  • @user2574616 Please create demo for a more accurate answer. – Tomas Santos Jul 15 '13 at 20:28
  • Turns out the radio button functionality is attached to the clicking of an image, so even though it appeared to be disabled, it could still be selected. I simply used ".unbind('click')" to disconnect from the click event. – user2574616 Jul 15 '13 at 21:36