I wanted to disable a button when the dialog is created initially. I enable this button later when the result is available, and needs to stay enabled. I tried to do it in create event, but doesn't work. If I move it to open, it hides the button but then it will be hidden whenever I open the dialog (even though I set it to show in the search callback). This is undesirable. I only need to hide the Select button till I enable it.
thanks for the help.
bsr.
$myWindow.dialog({ width: 400, autoOpen:false, title:'search',
overlay: { opacity: 0.5, background: 'black'}, modal: true,
open: function(event, ui) { $(".ui-dialog-titlebar-close").hide(); }, //to disable x on the title
create: function(event, ui) { $(".ui-dialog-buttonpane button:contains('Select')").button().hide(); },
buttons: {
"Select": function() { ... },
"Search": function() { ...
$(".ui-dialog-buttonpane button:contains('Search')").button().hide(); },
"Close": function() {$(this).dialog("close"); }
}
});
========== Edit:
to clear the scenario.
I have 3 buttons, as shown in the code, select, search and cancel.
1. when the user open the dialog first time, it shows 2 buttons (search and close)
2. when the user presses search, I disable search button as shown in the code
3. when the search result is obtained, I enable select button (not shown in the code, but it works).
4. Now, the user closes the dialog by pressing close.
5. now, if the user opens the dialog again, it preserves the previous state (and all the results).
everything works above except 1. that is how to hide select button till I enable it explicitly. The catch was i I disable it in "open" event, step 5 fails as it do not preserve the select button.
Edit 2:
Js Fiddle http://jsfiddle.net/kkh2a/
so the only thing I needed is to disable "Select" button till I explicitly display it in Search result call back (or when i click the search button here through button().show() )
thanks.