Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MaxLevels not working #64

Closed
lulubytt opened this issue Oct 13, 2021 · 12 comments
Closed

MaxLevels not working #64

lulubytt opened this issue Oct 13, 2021 · 12 comments

Comments

@lulubytt
Copy link

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!

@camohub
Copy link
Owner

camohub commented Oct 13, 2021

I test it right now. It works as expected. What is wrong?

@lulubytt
Copy link
Author

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?

@camohub
Copy link
Owner

camohub commented Oct 13, 2021

It seems the problem is in your code. I test it and it works. Can you create an online example or Github repository?

@lulubytt
Copy link
Author

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!

@camohub
Copy link
Owner

camohub commented Oct 14, 2021

You generate incorrect html structure. it has to be li>div not li>a

@lulubytt
Copy link
Author

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. :/

@camohub
Copy link
Owner

camohub commented Oct 14, 2021

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.

@camohub
Copy link
Owner

camohub commented Oct 14, 2021

Yes it seems it is a bug. It needs to be fixed. I am sorry.

@lulubytt
Copy link
Author

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!

@camohub
Copy link
Owner

camohub commented Oct 15, 2021

Ok I can.

@camohub
Copy link
Owner

camohub commented Oct 16, 2021

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.

@lulubytt
Copy link
Author

Worked like a charm! Thanks so much :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants