Help needet with multie level unordered list

Help needet with multie level unordered list

Hi,

I am making my first jquery plugin ( advance sitemap with Drag,Drop, Sort ) for my own cms system.

Plugin is 95% finished but with one bug which makes me crazy. My plugin supports how many levels can user add pages (example 3 level menu, 5 level menu ...).

Problem:
I am dragging element(ui.draggable) with below code and appending to other LI when drop. I can count parents (levels ul li) where i drop.

I can not count how many levels (ul li) has draggable element ( ui.draggable ), i tryed everything i know about jquery, please help me out.

ui.draggable:
  1. <li>
  2.       <ul>
  3.             <li>
  4.             ... MORE LEVELS
  5.             </li> 
  6.             <li></li>
  7.             ... MORE LEVELS
  8.       </ul>
  9. </li>
I count parent levels with this code ( Parent levels must be counted where i drop ) :
  1. var ParentCount = $(li).parents('li#page > ul').length;

I tryed counting max levels with:
  1. ui.draggable.children('li > ul')
    ui.draggable.find('li > ul')
So i need help with:
Nummber of max level ( UL LI ) in ui.draggable. Please help me out i wanna finish this plugin 100%.


Greatings from Slovenia and tnx in advance.