0


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.

2
  • I know it probably makes sense to you, but what you're trying to do here isn't super-clear from the wording in your question. Which button do you want to hide when the dialog opens? And which one do you want to show? And when exactly? Commented Apr 16, 2011 at 16:50
  • thanks.. edited for more clarity.. let me know. Commented Apr 16, 2011 at 16:58

1 Answer 1

1

Don't have your select be hidden unconditionally. When you enable it, throw a data attribute on it. Then, on dialog creation, check to see if it has the attribute and hide it if necessary.

Edit: if you want some quality help, I'm going to need a bit more code, personally. Throw up a jsfiddle?

An Answer: http://jsfiddle.net/kkh2a/1/

All I am doing here is disabling the button and hiding it, then removing the disable and showing it when you click on search.

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

3 Comments

so the only thing i need is to disable the select button, until i click search. I can do .button().show() there.. I am not much an expert, but your suggestion of flag with an attribute seems logical
@bsreekanth I added one way of solving this. Post if you need more.
i tried it y'day night quickly, and learned I could specify the id for button.. that would give me lot of possibilities.. I will verify it later today (it's sunday :-) ), would seek ur help if doesn't work and accept the answer.. thank you for the help.

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.