Note that there are some explanatory texts on larger screens.

plurals
  1. POjquery UI - simple example, what am I doing wrong?
    text
    copied!<p>I am trying to put some jquery UI code into an existing asp.net app, and could use a helping hand...</p> <p>I have a button, when a user clicks it, I want to popup a jquery UI dialog with two go/nogo confirmation buttons.</p> <p>This works except, when I click the button, it opens and then immediately closes...as a new jquery user, I am sure I am just missing something simple...</p> <p>Here is the javascript to open the dialog:</p> <pre><code>&lt;script type="text/javascript" &gt; $(function() { // Cancel Event Dialog Box $('#CancelDialog').dialog({ autoOpen: false, width: 500, buttons: { "Cancel This Event": function() {$(this).dialog("close");}, "Do Not Cancel": function() {$(this).dialog("close");} } }); }); &lt;/script&gt; </code></pre> <p>and here is the code that calls it:</p> <pre><code>&lt;asp:Button id="btnCancelMeeting" Text="Cancel Event" runat="server" /&gt; &lt;script language="javascript" type="text/javascript"&gt; $(document).ready(function() { $('#CancelDialog').dialog(); $('#btnCancelMeeting').click(function() {$('#CancelDialog').dialog('open'); }); }); &lt;/script&gt; &lt;div id="CancelDialog" title="Cancel and Event or Meeting"&gt;&lt;p&gt;Cancel this event.&lt;/p&gt;&lt;/div&gt; </code></pre> <p>To recap: I click the button, I get the dialog with the two buttons and message that I want, but it closes by itself about 1 second later...What am I doing wrong?</p> <p><strong>EDIT:</strong> OK, now I think I see what is going on...when I click the button, the dialog pops as desired, but then the page is reloading again from the server...which resets the entire page, including clearing the dialog.</p> <p>So what I really want to happen, is mimic this behavior:</p> <pre><code>&lt;asp:Button id="btnDelete" Text="Delete Event" runat="server" OnClientClick='javascript:return confirm(&amp;quot;Are you sure you would like to permanently delete this event/meeting? This action cannot be undone.&amp;quot;)' OnClick="btnDelete_Click" /&gt; </code></pre> <p>where the click generates a client-side event, and only if "OK" is chosen, does the page force a reload. Can anyone give the syntax for hanging this queryUI dialog box off of the OnClientClick event?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload