views:

117

answers:

4

Hey I'm trying to fire a new event I created for when a button is set to disabled state (By another method etc...) how can I achieve this? i want to listen for when the disabled state changes.

A: 

No. There is no event which is raised when the value of an attribute changes.

Ken Browning
+1  A: 

Why don't you just call the method from withing the method that disables the button?

function disableButton(){
     $('#the-button').attr('disabled', 'disabled');
     whatToDoWhenDisabled();
}

function whatToDoWhenDisabled(){
     Do whatever it is you do;
}
idrumgood
+1  A: 

If you do not necessarily have control of the disablement of the button there are two events you could look into:

onpropertychange (IE)

DOMAttrModified (w3c)

happytime harry
A: 

Id like to stay away from putting the code in the method which is being called just because i wanted to to be a site wide solution....

i was thinking of a while loop that doesn't end and does this

if($('#yourButton').is(':disabled')) { $('#someElement').trigger('yourEvent'); }

but the issue is that i don't want the JS slowing this page down would this be a issue...