Note that there are some explanatory texts on larger screens.

plurals
  1. POReusing jQuery-UI Dialog
    text
    copied!<p>I'm having all kinds of grief trying to re-use a jQuery-UI dialog. First time in everything works fine. Second time in, text fields have the previous values from first time through. In an attempt to make it work, in the click() function just after I do dialog("open") I manually clear the text fields values using <code>$("#fname, #lname, #email").val('');</code>. That effectively clears the fields for re-use but then when I submit the form using the serialize() method, the data being sent looks like this <code>fname=two&amp;lname=2&amp;email=two@aol.com&amp;fname=First+Name&amp;lname=Last+Name&amp;email=Email+ad dress</code>. "First Name", "Last Name" and "Email address" are watermarks set using some fieldtag plugin that I don't understand. </p> <p>The main question is, there must be some easy way to use the dialog a subsequent time with it initialized the way it was the first time. The close() method doesn't seem to do it. The dialog is being created with autoOpen set to false.</p> <pre><code>$("#user-form").dialog({ autoOpen: false, height: 400, width: 625, modal: true, resizable: false, open: function(event, ui) { $("#fname, #lname, #email").val(''); }, buttons: { "Update": function () { var bValid = true; allFields.removeClass("ui-state-error"); if (bValid) { $.get('AJAX/AddEditUser.php', $("#fname, #lname, #email").serialize(), function(){ $.get('users.php', function(data){ $("#contentcontainer").html(data); }); }); $(this).dialog("close"); $("#wholeArea").hide(); $("#placeholder").show(); $("div.content-area").load('home.html'); } }, Cancel: function () { $(this).dialog("close"); } }, close: function () { allFields.val("").removeClass("ui-state-error"); } }) </code></pre>
 

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