Hi,
I'm new to JQuery.I have a jQuery dialog. In this form, I have a "Save" button. I would like this "Save" button to be disabled while the modal dialog open or from a function.
The code i wrote to create this button is given below. However, I don't know how to enable and disable the dialog button from a function or at the time of loading the dialog. What should I do?
$('#divAddExpense').dialog({
modal: true,
autoOpen: false,
height: 'auto',
width: 650,
draggable: true,
position: 'center',
resizable: false,
buttons: { "Close": function () { $(this).dialog('close'); },
"Save": function (evt) {
//Save click code here
},
close: function () {
//some code
}
});
Plz help me out.
Loading
Amit ChoudharyPosted Jun 18, 2013, 4:20 PM
function getDialogButton( dialog_selector, button_name )
{
var buttons = $( dialog_selector + ' .ui-dialog-buttonpane button' );
for ( var i = 0; i < buttons.length; ++i )
{
var jButton = $( buttons[i] );
if ( jButton.text() == button_name )
{
return jButton;
}
}
return null;
}
you just need to pass your dialog selector and button name and it'll get disable based on you condition for e.g.
// now programmatically get the submit button and disable it
var button = getDialogButton( '.dialog1', 'Submit' );
if ( button )
{
button.attr('disabled', 'disabled' ).addClass( 'ui-state-disabled' );
}
Amit ChoudharyPosted Jun 18, 2013, 4:16 PM
Posted Jun 18, 2013, 6:40 AM
thnks for reply.The answer u have given,do u know when it'll execute.i think u didnt get my question properly.so plz dont answer like this.
Riyaz AkhtarPosted Jun 18, 2013, 6:32 AM
Sanjeeb LenkaPosted Jun 18, 2013, 6:19 AM
http://stackoverflow.com/questions/577548/how-can-i-disable-a-button-in-a-jquery-dialog-from-a-function
it may help you