Note that there are some explanatory texts on larger screens.

plurals
  1. POissues with jQuery plugin TreeView's toggle when unique set to true
    primarykey
    data
    text
    <p>I'm experimenting with TreeView plug-in located here: <a href="http://docs.jquery.com/Plugins/Treeview" rel="nofollow noreferrer">http://docs.jquery.com/Plugins/Treeview</a></p> <p>One of the options it has is "unique" - to have only one item expanded at a time.</p> <p>It works very well for display purposes, but then I try to hook in to the TreeView's "toggle" property/event to find out which one exactly was expanded.</p> <p>When "unique" is set to true, the function passed to "toggle" seems to get fired for each of the main list elements, preventing me from capturing which one actually initialized expansion. I see why that's done - to make sure other elements are toggled so only one is expanded.</p> <p>Any ideas on how get only the id of the "unique" list item that was toggled/expanded.</p> <p>example code below</p> <pre><code>$(document).ready(function() { $("#browser").treeview({ collapsed: true, unique: true, toggle: function() { $('#console').append(this.id + ' was toggled'); } }); }); &lt;ul&gt; &lt;li id="1"&gt;Ottawa &lt;ul&gt; &lt;li&gt;Item 1&lt;/li&gt; &lt;li&gt;Item 9&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;li id="2"&gt;Montreal &lt;ul&gt; &lt;li&gt;Item 2&lt;/li&gt; &lt;li&gt;Item 8&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;li id="3"&gt;Quebeque &lt;ul&gt; &lt;li&gt;Item 3&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;li id="4"&gt;Calgary &lt;ul&gt; &lt;li&gt;Item 7&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;li id="6"&gt;Toronto &lt;ul&gt; &lt;li&gt;Item 10&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;/ul&gt; &lt;div id="console"&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