0

I need to be able to enable and disable a linkbutton using javascript as part of a custom validator that I'm writing.

I discovered that setting "disabled=true" will disable a standard button, but it does nothing to a linkbutton.

After mucking about in JQuery I discovered that the following will actually disable the button:

$(button).click( function() { return false; }

Where button is a reference to the object. That works well. However, I can't for the life of me work out how to re-enable it! Neither of these seem to work:

$(button).click( function() { return true; }
$(button).click( function() { }

If anyone could either point me in the right direction to re-enable my button, or suggest a better way of disabling the button, It'd be appreciated.

Chers, Matt

1 Answer 1

2

I think you have to unbind the first event first.

Don't know in other versions, but in 1.4.2 you can attach multiple events, so the behaviour when you do this

$(button).click( function() { return false; } 
$(button).click( function() { return true; } 

will be 'return false;return true;'

$(button).unbind('click');
$(button).click( function() { return true; } 
Sign up to request clarification or add additional context in comments.

1 Comment

This is right, but $(button).click( function() { return true; } isn't neccesary, with the .unbind("click") is enough

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.