Note that there are some explanatory texts on larger screens.

plurals
  1. POjQuery UI Dialog Box using dialog() together with replaceWith()
    primarykey
    data
    text
    <p>I want to use jQuery UI dialog box to open a form dialog where one can edit information about an employee.<br /> The form looks like this</p> <pre><code>&lt;form id="formAddNewRow" action="/frontend_dev.php/test/create" method="post" &gt; &lt;table&gt; &lt;tbody&gt; &lt;ul&gt; &lt;li&gt; &lt;label for="employee_firstname"&gt;Firstname&lt;/label&gt; &lt;input type="text" name="employee[firstname]" id="employee_firstname" /&gt; &lt;/li&gt; &lt;li&gt; &lt;label for="employee_lastname"&gt;Lastname&lt;/label&gt; &lt;input type="text" name="employee[lastname]" id="employee_lastname" /&gt; &lt;/li&gt; &lt;ul&gt; &lt;/tbody&gt; &lt;/table&gt; &lt;/form&gt; </code></pre> <p>I want to load the form elements prefilled with the employees data. eg </p> <pre><code>&lt;label for="employee_lastname"&gt;Lastname&lt;/label&gt; &lt;input type="text" name="employee[lastname]" value="Miller" id="employee_lastname" /&gt; </code></pre> <p>So my idea was to ajax a complete form that fits the selected employee and replace it with the one above.</p> <pre><code>&lt;form id="formAddNewRow" action="/frontend_dev.php/test/create" method="post" &gt; &lt;table&gt; &lt;tbody&gt; &lt;ul&gt; &lt;li&gt; &lt;label for="employee_firstname"&gt;Firstname&lt;/label&gt; &lt;input type="text" name="employee[firstname]" value="Miller" id="employee_firstname" /&gt; &lt;/li&gt; &lt;li&gt; &lt;label for="employee_lastname"&gt;Lastname&lt;/label&gt; &lt;input type="text" name="employee[lastname]" value="Tom" id="employee_lastname" /&gt; &lt;/li&gt; &lt;ul&gt; &lt;/tbody&gt; &lt;/table&gt; &lt;/form&gt; </code></pre> <p>I try doing that by</p> <pre><code>$( ".editButton" ) .button() .click(function() { var replace = $.ajax({ url: 'employee/edit?id=1', success: function() { $( "#formAddNewRow" ).replaceWith(replace.responseText); } }); }); </code></pre> <p>This works, but it stops working when I do:</p> <pre><code>$( "#formAddNewRow" ).dialog({}); </code></pre> <p>There is no error message or warning. The form just gets eliminated from the DOM together with its parent node that was inserted by dialog().</p> <p>How do I prefill the form succesfully?</p>
    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.
    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