#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 follow-up: 2 Changed 12 years ago by
comment:2 Changed 12 years ago by
I need initialy disabled button with disabled state by using native UI methods. This workaround only prevents click action.
comment:3 Changed 12 years ago by
- 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.
- http://www.w3.org/TR/html401/struct/links.html#h-12.2
- http://www.w3.org/TR/html401/interact/forms.html#h-17.5
- http://www.w3.org/TR/html401/interact/forms.html#adef-disabled
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 12 years ago by
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 12 years ago by
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 12 years ago by
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 12 years ago by
Priority: | critical → major |
---|
comment:8 Changed 12 years ago by
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 12 years ago by
Resolution: | → duplicate |
---|---|
Status: | new → closed |
It seems to need something like this: