Note that there are some explanatory texts on larger screens.

plurals
  1. POHelp with a multilevel menu with json and jquery
    primarykey
    data
    text
    <p>I'm trying to do a multilevel menu that slides when ">" is clicked. The first issue is that the CSS is not working properly, the &lt; ul >'s aren't getting floated to the left.</p> <p>What I'm needing is show only one ul, and if ">" is clicked show the "children" menu sliding it or showing it, any method is useful.</p> <p>The complete code ready to test is <a href="http://jsfiddle.net/seinoxygen/CxBrW/" rel="nofollow">here</a></p> <p>I'm trying to do this: <a href="http://www.slashc.com/codecanyon/jquery_infinite_sliding_menu/index.html" rel="nofollow">menu</a></p> <p>JavaScript</p> <pre><code>$(document).ready(function(){ var json = [{"id":"1","parent":"0","slug":"digitalart","name":"Digital Art"},{"id":"2","parent":"1","slug":"3d","name":"3-Dimensional Art"},{"id":"39","parent":"1","slug":"drawings","name":"Drawings"},{"id":"3","parent":"2","slug":"abstract","name":"Abstract"},{"id":"4","parent":"2","slug":"characters","name":"Characters"},{"id":"12","parent":"2","slug":"objects","name":"Objects"},{"id":"23","parent":"2","slug":"scenes","name":"Scenes"},{"id":"32","parent":"2","slug":"unsorted","name":"Unsorted"},{"id":"33","parent":"2","slug":"vehicles","name":"Vehicles"},{"id":"5","parent":"4","slug":"creatures","name":"Animals &amp; Creatures"},{"id":"6","parent":"4","slug":"cartoon","name":"Cartoon"},{"id":"7","parent":"4","slug":"female","name":"Female"},{"id":"8","parent":"4","slug":"groups","name":"Groups"},{"id":"9","parent":"4","slug":"machines","name":"Machines &amp; Robots"},{"id":"10","parent":"4","slug":"male","name":"Male"},{"id":"11","parent":"4","slug":"misc","name":"Miscellaneus"}]; build_menu(json, 0); }); function build_menu(json, parent){ var menu; var item = ""; var counter = 0; if(parent != '0'){ item += '&lt;li&gt;&lt;a class="more" onClick="show(); return false;" href="#"&gt;Back&lt;/a&gt;&lt;/li&gt;'; } $.each(json, function(i, category) { if(category.parent == parent){ var more = '&lt;a class="more" onClick="show('+parent+'); return false;" href="#"&gt;&gt;&lt;/a&gt;'; item = item + '&lt;li&gt;' + category.name + more + '&lt;/li&gt;'; build_menu(json, category.id); counter++; } }); if(counter &gt; 0){ menu = '&lt;ul class="menu" id="category' + parent + '"&gt;' + item + '&lt;/ul&gt;'; $('#menu').prepend(menu); } } function show(id){ $(".menu").hide(); $("#category"+id).show(); } </code></pre> <p>css</p> <pre><code>#menu{ width: 180px; overflow: hidden; } #menu ul{ width: 180px; float: left; list-style: none; } #menu ul li{ border: solid 1px black; margin-bottom: 5px; } #menu li .more{ //float: right; text-decoration: none; margin-right: 5px; } </code></pre> <p>html</p> <pre><code>&lt;div id="menu"&gt; &lt;/div&gt; </code></pre>
    singulars
    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.
 

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