Link to home
Start Free TrialLog in
Avatar of hb69
hb69

asked on

Question: JQuery UI Diaolg on Button Click

Does anyone know how to get any variant of the JQuery UI Modal Dialog to pop up and stay popped up when the user clicks a button?

I got the default example working great on my local machine (http://jqueryui.com/demos/dialog/#modal-confirmation).  The default example pops up on docready.  No problem.  Then I wanted it to only pop up when the user clicks "submit" on a form.  I thought this would take seven seconds, and seven hours later I'm out of options.

No code sample provided. ANY pointing in the right direction or any sample will be greatly appreciated.  BTW - I can get the modal dialog to pupup on the click event, but it disappears in a split second because of postback / form submit.  I'd think the modal: true would stop form submit in the same way that alert('hello world'); will totally stop a form submit but ... nope it doesn't.

Anyone?  Thanks in advance.
ASKER CERTIFIED SOLUTION
Avatar of alien109
alien109
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of hb69
hb69

ASKER

Here's the deal.  I'm going to give you the points because what you suggested worked in non IE browsers.  That it totally crashes Internet Explorer is not your fault and not a fault of your solution.  But, none the less I cannot do what you suggested because of a well known IE issue.  I'm using .net BTW.

If you are aware of how to work around the IE Bug (freezes the screen so hard that you can't even close IE except through the task manager and even then doesn't shut down gracefully) you or somebody else should post that as a separate solution.

Thanks!
Avatar of hb69

ASKER

Very good, except for the IE Bug that makes it impossible to implement your suggestion.
Avatar of hb69

ASKER

UPDATE:

I used a workaround and rescued my pretty dialog box from oblivion.  What I did was I created two panels on my form.  During initial login we show one panel.  That panel does not contain the <div> for the UI Dialog, and it does not contain the JS.  IF upon postback the conditions exist for the dialog to display, I then set the first panel to visible=false, and visible = true to the other panel which contains the dialog box and it's JS.  It pops up and asks it's questions.

Apparently, IE is totally OK with this solution.  It does not affect how the javascript is written, but does affect when it can be placed on the page.  I don't know if this is the best solution or even a good solution but it works and I'm moving forward with it.

Adding the attribute to the form itself (onSubmit do this)  so that a validate javascript halts the execution of code seems to not work well in .net/IE.  So my advice for those who read this is if you are using .net, then place your dialog in panels and show the panel with the dialog as needed, and place all dialog code (html and js) inside of that panel.