Coder Social home page Coder Social logo

Comments (10)

FlameArt avatar FlameArt commented on July 18, 2024 1

It is true: after i added id attribute to a <li> elements, problem had been solved.

from nestedsortable.

Rene-Sackers avatar Rene-Sackers commented on July 18, 2024

Simply removing the if statement in its entirety seems to help (of course leaving the trigger), but are there any consequences to this?

from nestedsortable.

KarelCemus avatar KarelCemus commented on July 18, 2024

I confirm the issue.

I honestly have no clue what this if statement is supposed to do, or mean, so I'm a bit afraid to touch it.

Btw, I debugged it and IMHO you can safely remove it. I guess the following meaning:

this._pid_current === this._uiHash().item.parent().parent().attr("id")

_pid_current should contain the id of the source list, while the right side reads id of the target list.

this._sort_current === this._uiHash().item.index())

_sort_current should contain index of the item in the source list and the right side reads the index in the target list.

IMHO the issue occurs when there are multiple lists without ids and the movement among them on the same level. Then the condition results in if ( ! (undefined === undefined && index === index ) ) which is always false that is why the event is not fired.

If my explanation is correct, there is only one consequence of the if removal: The event will we fired even when no actual movement is performed, i.e., when the position remains same.

from nestedsortable.

lllopo avatar lllopo commented on July 18, 2024

I confirm - if you use other than 'id' attribute ... something like 'data-id' or something - th eproblem occurs. The attribute shouldn't be hardcoded, since other stuff like toArray method make it flexible.

from nestedsortable.

ilikenwf avatar ilikenwf commented on July 18, 2024

Put in a pull request to fix it?

from nestedsortable.

KarelCemus avatar KarelCemus commented on July 18, 2024

Any suggestion how to workaround this consequence?

The event will we fired even when no actual movement is performed, i.e., when the position remains same.

I think of keeping this with && id !== undefined. That would reduce the impact of this consequence to trees without ids. But still it is not optimal. Thoughts?

I'd create the PR then.

from nestedsortable.

lllopo avatar lllopo commented on July 18, 2024

This won't help, as it will effectively turn of the identification of the leaves. The real solution would be to add an option to define the ID holding html attribute (same as the one used by toArray), default it to 'id' and use it on both places - in relocate and _clear methods.

from nestedsortable.

KarelCemus avatar KarelCemus commented on July 18, 2024

Would you take care of it, @lllopo? Sounds you've thought it through.

from nestedsortable.

Substractive avatar Substractive commented on July 18, 2024

Good day , I encountered same problem since there is no official fix for that I created workaround outside the plugin, for my case I have used update function and there I retrieve id of the item that is moved after that jQuery grab that item and find it's parent..

Here is my example if someone is curious..
$('.sortable').nestedSortable({ handle: 'div', items: 'li', maxLevels:0, toleranceElement: '> div', update: function(event,ui) { treeChange(ui.item.attr("id"),$("#"+ui.item.attr("id")).parent().parent().attr("id")); } });

from nestedsortable.

NiklasMouritzsen avatar NiklasMouritzsen commented on July 18, 2024

I was experiencing the same issue, the solution suggested by @FlameArt did the trick. I simply added <li id="*someid*">···</li>

from nestedsortable.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.