1

I am using jquery ui dialog. In the dialog i have 1 save button, when user click on the save button in the callback of the save button i am disabling it. My code :

$("#Form1").dialog({
    width: 500, autoOpen: false, modal: true, resizable: false, draggable: false,
    buttons: {
        "Save": function (event, ui) {
            $(event.currentTarget).button({ disabled: true });
             ... .
             ....
         }
    }
    , beforeClose: function () {
        //here how can i enable the save button
    }
});

Now my problem is that when user open the dialog again the save button still disabled so thats why i want to enable the button at dialog beforeClose event. How can i do this?

1
  • one way might be to save the value of event.currentTarget as an attribute of the dialog Commented Oct 30, 2012 at 11:47

2 Answers 2

1

The element you invoke the dialog on gets wrapped in a parent so title bar, buttons etc can be added. All the buttons have class ui-button

This should do what you need

beforeClose:function(){
   $(this).parent().find('.ui-button').button({ disabled: false });

}
Sign up to request clarification or add additional context in comments.

Comments

0

You might find it easier to enable and disable the button in the following way:

btn_save = $('#Form1').parent().find(':button:contains("save")');

//disable the save button
$(btn_save).prop('disabled', true).addClass('ui-state-disabled');

//enable the save button
$(btn_save).prop('disabled', false).removeClass('ui-state-disabled');

The added css class will give the button it's disabled css styling. Also note that the :contains selector is case sensitive.

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.