javascript - How to limit NestedSortables sublevels? -


i use http://mootools.net/forge/p/nestedsortables sort list of li elements, can sort them unlimited sublevels. need limit 1 sublevel.

https://jsfiddle.net/dq3xqvu9/

new nestedsortables('menu', {   onstart: function(el) {  },   oncomplete: function(el) {  } }); 

good - want able move them 1 sublevel:

  • list item
    • list item
    • list item
    • list item

not - default nestedsortables allows move items unlimited sublevels like:

  • list item
    • list item
      • list item
        • list item

i added these 3 restrictions nestedsortables class:

  abort += (this.getdepth(dest, (move == 'inside')) > 1);   abort += ((move == 'inside') && (el.getfirst('ul') != null));   abort += ((move != 'inside') && (el.getfirst('ul') != null) && (this.getdepth(dest, (move == 'inside')) > 0)); 

complete code on updated jsfiddle.

this modification limits number of sub-levels 1.


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -