Coder Social home page Coder Social logo

Error when using toArray about nestedsortable HOT 2 OPEN

ilikenwf avatar ilikenwf commented on July 18, 2024
Error when using toArray

from nestedsortable.

Comments (2)

TheSin- avatar TheSin- commented on July 18, 2024 4

After reading the code, I see now that the item id (or id attribute) NEEDS to be key[=-_]id, I didn't not find this in the doc at all and I was just setting it to id. so data-id="1", this causes a the error, I had to change to data-id="idontcare_1" which is ugly. To that end changing expression to some that does not return an array of 3 items would also break it. This doesn't seem like a great fix.

I'd recommend setting a default expression to /.+[=-_](.+)/ so it's only returning one item which is the id. that way other can just override the expression to return /(.*)/ for like in my case and chang the code to expect only one, so parentItem[0] instead of parentItem[2].

Anyhow I hope the helps other and I wish I didn't have to ugly up my html to make this work, but at least it's working now ;) I'll leave this open for other and incase you want to fix this in the future.

from nestedsortable.

austingray avatar austingray commented on July 18, 2024

Yes kind of a pain, you need to set the li element's id to be 'text_123' instead of '123'. Tacking on this comment so people can search for the console error I received and easily find this thread:

jquery.mjs.nestedSortable.js?ver=2.1a:784 Uncaught TypeError: Cannot read property '2' of null

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.