{"action":"created","issue":{"url":"https://api.github.com/repos/vespakoen/menu/issues/111","labels_url":"https://api.github.com/repos/vespakoen/menu/issues/111/labels{/name}","comments_url":"https://api.github.com/repos/vespakoen/menu/issues/111/comments","events_url":"https://api.github.com/repos/vespakoen/menu/issues/111/events","html_url":"https://github.com/vespakoen/menu/issues/111","id":123160686,"number":111,"title":"Unlimited submenus","user":{"login":"mgsmus","id":543371,"avatar_url":"https://avatars.githubusercontent.com/u/543371?v=3","gravatar_id":"","url":"https://api.github.com/users/mgsmus","html_url":"https://github.com/mgsmus","followers_url":"https://api.github.com/users/mgsmus/followers","following_url":"https://api.github.com/users/mgsmus/following{/other_user}","gists_url":"https://api.github.com/users/mgsmus/gists{/gist_id}","starred_url":"https://api.github.com/users/mgsmus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mgsmus/subscriptions","organizations_url":"https://api.github.com/users/mgsmus/orgs","repos_url":"https://api.github.com/users/mgsmus/repos","events_url":"https://api.github.com/users/mgsmus/events{/privacy}","received_events_url":"https://api.github.com/users/mgsmus/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-12-20T13:49:13Z","updated_at":"2015-12-20T19:53:22Z","closed_at":null,"body":"```\r\n<ul handler=\"main\" class=\"nav navbar-nav\">\r\n    <li><a href=\"#\">Item 1</a></li>\r\n    <li><a href=\"#\">Item 2</a></li>\r\n    <li class=\"dropdown\"><a class=\"dropdown-toggle\" data-toggle=\"dropdown\" href=\"#\">Item 3</a>\r\n        <ul class=\"dropdown-menu\">\r\n            <li class=\"dropdown-submenu\"><a href=\"#\">Item 3.1</a>\r\n                <ul class=\"dropdown-menu\">\r\n                    <li><a href=\"#\">Item 3.1.1</a></li>\r\n                    <li><a href=\"#\">Item 3.1.2</a></li>\r\n                    <li class=\"dropdown-submenu\"><a href=\"#\">Item 3.1.3</a>\r\n                        <ul class=\"dropdown-menu\">\r\n                            <li><a href=\"#\">Item 3.1.3.1</a></li>\r\n                            <li><a href=\"#\">Item 3.1.3.2</a></li>\r\n                            <li><a href=\"#\">Item 3.1.3.3</a></li>\r\n                        </ul>\r\n                    </li>\r\n                </ul>\r\n            </li>\r\n            <li><a href=\"#\">Item 3.2</a></li>\r\n            <li><a href=\"#\">Item 3.3</a></li>\r\n        </ul>\r\n    </li>\r\n    <li><a href=\"#\">Item 4</a></li>\r\n</ul>\r\n```\r\n\r\nHow can I achive a structure like this? \r\n\r\n- If a dropdown contains another dropdown, inner dropdown's parent li element gets .dropdown-submenu class\r\n\r\n- First \"a\" after .dropdown-submenu shouldn't have class=\"dropdown-toggle\" and data-toggle=\"dropdown\"\r\n\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/vespakoen/menu/issues/comments/166150068","html_url":"https://github.com/vespakoen/menu/issues/111#issuecomment-166150068","issue_url":"https://api.github.com/repos/vespakoen/menu/issues/111","id":166150068,"user":{"login":"mgsmus","id":543371,"avatar_url":"https://avatars.githubusercontent.com/u/543371?v=3","gravatar_id":"","url":"https://api.github.com/users/mgsmus","html_url":"https://github.com/mgsmus","followers_url":"https://api.github.com/users/mgsmus/followers","following_url":"https://api.github.com/users/mgsmus/following{/other_user}","gists_url":"https://api.github.com/users/mgsmus/gists{/gist_id}","starred_url":"https://api.github.com/users/mgsmus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mgsmus/subscriptions","organizations_url":"https://api.github.com/users/mgsmus/orgs","repos_url":"https://api.github.com/users/mgsmus/repos","events_url":"https://api.github.com/users/mgsmus/events{/privacy}","received_events_url":"https://api.github.com/users/mgsmus/received_events","type":"User","site_admin":false},"created_at":"2015-12-20T19:53:22Z","updated_at":"2015-12-20T19:53:22Z","body":"```php\r\n$menu->handler('main')->addClass('nav navbar-nav');\r\n\r\n$menu->getItemsAtDepthRange(0, 1)->map(function ($item) {\r\n    if ($item->hasChildren()) {\r\n        $item->addClass('dropdown');\r\n    }\r\n});\r\n\r\n$menu->getItemsAtDepth(0)->map(function ($item) {\r\n    if ($item->hasChildren()) {\r\n        $item->getContent()\r\n            ->addClass('dropdown-toggle')\r\n            ->setAttribute('data-toggle', 'dropdown')\r\n            ->setAttribute('data-hover', 'dropdown');\r\n    }\r\n});\r\n\r\n$menu->getItemsAtDepthRange(1, 3)->map(function ($item) {\r\n    if ($item->hasChildren()) {\r\n        $item->removeClass('dropdown')->addClass('dropdown-submenu');\r\n    }\r\n});\r\n\r\n$menu->getItemListsAtDepthRange(1, 3)->map(function ($item) {\r\n    if ($item->hasChildren()) {\r\n        $item->addClass('dropdown-menu');\r\n    }\r\n});\r\n```\r\n\r\nI finally did it but I don't know if it's a good approach"}}