[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now


Question: JQuery UI Diaolg on Button Click

Posted on 2009-05-11
Medium Priority
Last Modified: 2013-11-05
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.
Question by:hb69
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
LVL 12

Accepted Solution

alien109 earned 1500 total points
ID: 24358865
shouldn't be too tough...

add an onsubmit event handler to the form (that returns false!) then in that handler function get the node that holds the content you want displayed and execute the dialog method.

something like:
<script type="text/javascript">
function openDialog() {
    return false;

<div id="dialogContent" style="display:none;">Hi there</div>
<form id="test" onsubmit="return openDialog();">

Author Comment

ID: 24364383
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.


Author Closing Comment

ID: 31580319
Very good, except for the IE Bug that makes it impossible to implement your suggestion.

Author Comment

ID: 24366110

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.

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Requirements JQuery 1.6+ HTML CSS Introduction This article was inspired by an EE question (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28372511.html) on how to make a page show some balloons animate up a page…
Introduction If you're like most people, you have occasionally made a typographical error when you're entering information into an online form.  And to your consternation, the browser remembers the error, and offers to autocomplete your future entr…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
Suggested Courses

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question