Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
96
rated 0 times [  102] [ 6]  / answers: 1 / hits: 40055  / 13 Years ago, wed, june 22, 2011, 12:00:00

I have a jQuery Mobile Beta 1 website with jQuery 1.6.1 link button like this:



<a id=subselection href=# data-role=button data-theme=b>TEST</a>


And in document.ready i set the click event:



$('#subselection').livequery(click, function(){
alert('test');
});


I whant to disable this link button and i tried



$('#subselection').button('disable')


And that command set the button style like it is disabled but the click event works.



I have also tried



$('#subselection').prop('disabled', true);


and $('#subselection').prop('disabled'); gives true but its not disabled.



Someone has a good idea.


More From » jquery

 Answers
41

The a element does not have a property disabled. So defining one won't affect any event handlers you may have attached to it.



example: http://jsfiddle.net/niklasvh/n2eYS/



For a list of available attributes, have a look at the HTML 5 reference.



To solve your problem, you could instead for example assign the disabled as data in the element:



$('#subselection').data('disabled',true);



and then in your event check if its set:



if (!$(this).data('disabled'))



example: http://jsfiddle.net/niklasvh/n2eYS/5/


[#91573] Tuesday, June 21, 2011, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
aidan

Total Points: 72
Total Questions: 95
Total Answers: 121

Location: Uzbekistan
Member since Sat, Feb 27, 2021
3 Years ago
;