Opened 9 years ago

Closed 9 years ago

Last modified 7 years ago

#5951 closed bug (duplicate)

Button from A tag can't be disabled

Reported by: vs-pvt Owned by:
Priority: major Milestone:
Component: ui.button Version: 1.8.4
Keywords: Cc:
Blocked by: Blocking:

Description

<a id="button" href="#">Disabled button</a>
<script type="text/javascript">
  jQuery('#button').button({ disabled: true });
</script>

UI generates button but it's can't be disabled. Invoking method .button('disable') do nothing too (((

Change History (11)

comment:1 Changed 9 years ago by watanabe

It seems to need something like this:

 $("#button").click(function () {
  if ($(this).attr("disabled")) return false;
 });

comment:2 in reply to:  1 Changed 9 years ago by vs-pvt

I need initialy disabled button with disabled state by using native UI methods. This workaround only prevents click action.

comment:3 Changed 9 years ago by watanabe

  • The "A" element seems to have no "native" UI method to prevent click action.
  • The "BUTTON" element seems to have the "disabled" attribute to prevent click action.

In IE8, when disabling the "A" element, the element seems to be grayed out, do not receive focus, but can be clicked.

comment:4 Changed 9 years ago by fastfasterfastest

I am running into this problem as well - but only in Firefox.

If I turn an "A" element into a jQuery UI button, then disable the button, then click on the button then:

  • in IE8, the buttons click event handler will not be invoked (good)
  • in Firefox 3.6.8, the buttons click event handler will be invoked (bad)


Same behavior is experienced if the button is disabled with .attr("disabled", "disabled").

Here is my sample code:
<a href="#" id="a1">Test</a>
<script type="text/javascript">
$(function() {

$('#a1').button().button("option", "disabled", true).click(function() { alert("clicked") });

});
</script>

comment:5 Changed 9 years ago by watanabe

It seems the "disabled" attribute of the "A" element does not prevent the click action in IE8.0.6001.18943, Chrome 6.0.472.53, Safari 3.2.2(525.28.1), Firefox 3.6.6, Opera 10.53.

<a href="about:blank" id="a1" target="_blank" onclick="alert('obtrusive')" disabled="disabled">Test</a>

But it seems ".button({ disabled: true })" prevent the click action in IE8, not in other browsers.

$('#a1').button({ disabled: true });

jQuery( or jQuery UI) code may prevent the click action in IE8.

The "disabled" attribute of the "A" element (half-implemented in IE) may have something to do with this behavior.

alert( $("#a1").attr("disabled") === true )
  • In IE8, this code shows "true".
  • In other browsers, this code shows "false".

comment:6 Changed 9 years ago by watanabe

jQuery UI code may prevent the click action in IE8.

<A class="ui-button" disabled="disabled" onclick="alert('obtrusive')" href="about:blank" target="_blank">test</A>

comment:7 Changed 9 years ago by Scott González

Priority: criticalmajor

comment:8 Changed 9 years ago by davidmurdoch

I could not reproduce this issue with jQuery UI 1.9pre Live from Git Tue May 17 14:55:04 UTC 2011.

comment:9 Changed 9 years ago by Scott González

Resolution: duplicate
Status: newclosed

comment:10 Changed 9 years ago by Scott González

Duplicate of #5945.

comment:11 Changed 7 years ago by Scott González

Milestone: TBD

Milestone TBD deleted

Note: See TracTickets for help on using tickets.