0

How can i disable the jquery UI dialog buttons like :

   $("#dialog").dialog({ width: 500, modal: true, show: 'drop', hide: 'drop',
        buttons: {
            "Next": function () {/* do something */ },
            "Finish" : function {/* do something */ } 
        }
    });

I want to keep disabled the Next button until user selects some radio button or checkbox and when user will select any of then 'Next button will enabled'. (Same behavior which we can see when we install any new software.).How can i do this?

1
  • I assume they have a set id or class, just set some event listeners with .on or .live (depending on jQuery version) calling for a validation/check function, it can't be that hard. Commented Jun 1, 2012 at 7:30

3 Answers 3

1

You can use firebug or inspect element from google chrome then find next button id or css rule... I mean a correct selector to the button then you can always call

$("Nextbutton selector").attr('disabled','disabled');

re enable by

$("Nextbutton selector").removeAttr('disabled');

hope this help

PS: When inspect i saw

<button class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" type="button" role="button" aria-disabled="false">
<span class="ui-button-text">Next</span>
</button>

so you can call

$('button.ui-button:contains("Next")').attr....
Sign up to request clarification or add additional context in comments.

3 Comments

but how we can give the id to dialogs Next button`
Jquery usually do that itself, you cant change that
I just suggest a selector, can you try?
0

To enable:

$(e.currentTarget).button( "option", "disabled", false );

To disable:

$(e.currentTarget).button( "option", "disabled", true );

Button Widget API

Comments

0

Right after creating and opening the dialog, which is what this (your code) does:

 $("#dialog").dialog({ width: 500, modal: true, show: 'drop', hide: 'drop',
    buttons: {
        "Next": function () {/* do something */ },
        "Finish" : function {/* do something */ } 
    }
 });

Do this:

 $("#dialog").dialog('widget')
     .find("button :contains('Next')").parent().button("disable");

It will immediately disable the "Next" button. When ready, you can enable the button by doing:

 $("#dialog").dialog('widget')
     .find("button :contains('Next')").parent().button("enable");

Comments

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.