Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to get the id of the parent and the position of an li item
    primarykey
    data
    text
    <p>I want to change a nested Navigation by drag and drop and i find a nice plugin. Now i want to store the changes in the database, but unfortually I can't read out the id of the parent element. The second thing what I need is the new position of the dragged li element in the list</p> <pre><code>&lt;script type="text/javascript" src="includes/jquery/jquery.js"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="includes/jquery/interface.js"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="includes/jquery/inestedsortable-1.0.pack.js"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; jQuery( function($) { $('#Hnav, #Nnav').NestedSortable( { accept: 'sort', noNestingClass: "no-children", helperclass: 'helper', autoScroll: true, onChange: function(serialized) { onStop : function(){ $('#output').html($(this).id); // works fine $('#output').html($(this).parent().parent().att('id')); // fail $('#output').html(this.closest('li').att('id')); // fail }, nestingPxSpace : '0' } ); }); &lt;/script&gt; </code></pre> <hr> <p>html</p> <pre><code>&lt;div id="sitemap"&gt; &lt;ul id="Hnav"&gt; &lt;li id="n1"&gt;&lt;a href="contentsite.php?cont=1"&gt;Home&lt;/a&gt;&lt;/li&gt; &lt;li id="n2" class="sort"&gt;&lt;a href="contentsite.php?cont=2"&gt;Choir&lt;/a&gt; &lt;ul class="level2"&gt; &lt;li id="n4" class="sort"&gt;&lt;a href="contentsite.php?cont=3"&gt;lkff&lt;/a&gt;&lt;/li&gt; &lt;li id="n6" class="sort"&gt;&lt;a href="contentsite.php?cont=5"&gt;changethis&lt;/a&gt;&lt;/li&gt; &lt;li id="n5" class="sort"&gt;&lt;a href="contentsite.php?cont=4"&gt;History&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; </code></pre> <h2>...</h2> <p>Any idea? Thank you.</p> <p>Lara</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.
 

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