Note that there are some explanatory texts on larger screens.

plurals
  1. POslidetoggle reset state on AJAX Post
    primarykey
    data
    text
    <p>I've run into a bit of a problem that I'm hoping you can help me with. I've got a form that opens with slidetoggle(); Works like a charm. The form inside that element #dialog the performs an AJAX Post submit. All works to perfection.</p> <p>Here's the problem: When the form is submitted, slidetoggle seems to lose its state, and when the user then subsequently clicks the button that fires the slidetoggle, nothing happens. If I refresh the main page in my success function, then everything works as expected - however that seems to defeat the purpose of an AJAX Post submit in the first place. Here's my code:</p> <pre><code> $.ajax( { type: "POST", url: "{U_NEW}", data: dataString, success: function() { $('#reply-dialog').html("&lt;div id='succes'&gt;&lt;/div&gt;"); $('#succes').html("&lt;h2&gt;{L_DRAFT_SAVED}&lt;/h2&gt;") .hide() .fadeIn(800, function() { $('#succes') }); $('#succes').delay(2000).slideUp(500, function() { location.reload(); parent.conversations.location='{U_CONVERSATIONS}'; }); } }); </code></pre> <p>The code that fires the slidetoggle:</p> <pre><code>$(function() { $("#new").click(function () { $("#dialog").slideToggle("100"); }); }); </code></pre> <p>And the #dialog div</p> <pre><code> &lt;div id="dialog"&gt; &lt;div class="ui-state-highlight ui-corner-all" style="padding: .7em;"&gt; &lt;div class="ui-widget"&gt; &lt;form action=""&gt; &lt;fieldset style="border: none;"&gt; &lt;h2&gt;{L_NEW_MESSAGE}&lt;/h2&gt; &lt;label for="recipient" id="recipient_label"&gt;{L_RECIPIENT}: &lt;span class="small-font"&gt;{L_RECIPIENT_EXPLAIN}&lt;/span&gt;&lt;/label&gt;&lt;/label&gt; &lt;br /&gt; &lt;input type="text" name="recipient" id="recipient" value="" class="text ui-widget-content ui-corner-all" /&gt; &lt;label class="error" for="recipient" id="recipient_error"&gt;{L_FIELD_REQUIRED}&lt;/label&gt; &lt;label class="error" for="recipient" id="recipient_name_error"&gt;{L_RECIPIENT_NOT_FOUND}&lt;/label&gt; &lt;br /&gt; &lt;label for="subject" id="subject_label"&gt;{L_SUBJECT}:&lt;/label&gt; &lt;br /&gt; &lt;input type="text" name="subject" id="subject" class="text ui-widget-content ui-corner-all" /&gt; &lt;label class="error" for="subject" id="subject_error"&gt;{L_FIELD_REQUIRED}&lt;/label&gt; &lt;br /&gt; &lt;label for="message" id="message_label"&gt;{L_MESSAGE}:&lt;/label&gt; &lt;br /&gt; &lt;textarea name="message" style="width: 99%;" rows="10" id="message" class="text ui-widget-content ui-corner-all"&gt;&lt;/textarea&gt; &lt;label class="error" for="message" id="message_error"&gt;{L_FIELD_REQUIRED}&lt;/label&gt; &lt;input type="submit" name="submit" id="button" value="{L_SEND_MESSAGE}" /&gt; &lt;input type="submit" name="draft" id="draft" value="{L_SAVE_AS_A_DRAFT}" /&gt; &lt;/fieldset&gt; &lt;/form&gt; &lt;/div&gt; &lt;/div&gt; &lt;br /&gt; &lt;/div&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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