Closed lulubytt closed 3 years ago
I test it right now. It works as expected. What is wrong?
I am creating a dynamic menu. The user can drag and nest the menu items as they wish, but I want to allow only 2 levels of nesting. However, when I add the option {maxLevels : 2}, the nesting capabilities during the drag and drop are gone. It only allows me to change the order. I don't have any other options that might be conflicting.
Nesting works when MaxLevels is off. Nesting does not work when MaxLevels has a value. Just wondering if you can think of a reason this would happen?
It seems the problem is in your code. I test it and it works. Can you create an online example or Github repository?
Hi, so I did a couple of tests and I figured out that the plugin works well when you have static HTML laid out to begin with. But when you add content dynamically, like I'm trying to do, it fails. I made a simplified version of what I'm trying to do here so you can see for yourself:
https://github.com/lulubytt/jquery-sortable-lists-test
thanks!
You generate incorrect html structure. it has to be li>div not li>a
Thanks for taking a look. You're right, I tried first with the correct html structure: li>div but that didn't work either, so I removed the div to see what would happen. Neither work. I just changed it back to the correct structure and you can see in my repo that it still doesn't work. :/
Another problem is the maxLevels needs to add data-upperLevels and data-insideLevels attribute to the li element if you generate it. Although it seems the javascript demaged the data attribute and change upper L in the attribute name data-insideLevels to the lowercase. So plugin can not find the attribute.
Yes it seems it is a bug. It needs to be fixed. I am sorry.
No worries! I will be more than happy to make a donation to your account if you think you can get this fixed within the next week or so? Thanks!
Ok I can.
Hi, I fixed it. Try the newest version 2.4 and use minified version please.
Added item has to have data-upper-level="0"
and data-inside-levels="0"
attributes.
Let me know how it turned out.
Worked like a charm! Thanks so much :)
Hello @camohub! Thanks for a great plugin, this has saved me hours of dev work. :)
One issue though: the maxLevels options is not working. When I set it to a number, it stops nesting altogether. If I remove the maxLevels option (it defaults to false), it starts nesting again.
Please advise. Thanks!