Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Regarding the problem where your row gets insertet at the top: </p> <ul> <li>Like Bertrand Lefort already said: in JQuery you can append nodes to the <strong>end</strong> of another (parent) node by calling <code>parent_node.append(child_node)</code> (more information <a href="http://api.jquery.com/append/" rel="nofollow">here</a>)</li> <li>You can also add elements before/after another element by calling <a href="http://api.jquery.com/before/" rel="nofollow"><code>another_element.before(element)</code></a> / <a href="http://api.jquery.com/after/" rel="nofollow"><code>another_element.after(element)</code></a> or (be aware of reversed syntax!) <a href="http://api.jquery.com/insertBefore/" rel="nofollow"><code>element.insertBefore(another_element)</code></a> / <a href="http://api.jquery.com/insertAfter/" rel="nofollow"><code>element.insertAfter(another_element)</code></a></li> </ul> <p>Regarding the problem where only the first "add a row" registers a click: </p> <ul> <li>You're selecting by <code>id</code>. Id's are (or should be) unique, so when you call <code>$("#additemrow").click(function(){ ... })</code> the onClick-function will only be attached to the first element that matches the given id (as far as I remember). </li> <li>If you want to attach the same onClick-function to multiple elements use <code>class</code> instead. However, if you do so, you got to make sure you insert the new element <em>relative</em> to the clicked element (eg. by using <code>.parent()</code>, <code>.siblings()</code> or similar functions).</li> </ul> <p>Regarding your problem #2, I don't really know what you're trying to do, but this is what I noticed:</p> <ul> <li><code>currentListItem</code> and <code>currentJobItem</code> seem to be unused in their scope, since you are declaring them as local variables but not using them</li> <li><code>.parents('#items').index('#items')</code> is redundant because <code>.parents('#items')</code> already selects only the parent elements that match <code>'#items'</code>. If you want to get the index of the matched element, use <code>index()</code> (without parameters, <a href="http://api.jquery.com/index/" rel="nofollow">see jquery API for more</a>)</li> </ul> <p>Some other notes:</p> <ul> <li>If you have the time (and the need of a clean project) I recommend using template engines like Smarty to separate your logic from the output. This improves the readability of your code and also makes it easier to find/eliminate bugs.</li> </ul> <p>I hope this helped a little bit. If you provide more information on what you're trying to do and what doesn't work as you expext, I will try to provide further help and update my answer.</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