Giter VIP home page Giter VIP logo

Comments (9)

kicsiede avatar kicsiede commented on July 30, 2024

also "falsy" values in the array such as false, 0, undefined prevents updating the observable array even though the ui drop seems to happen.

from knockout-sortable.

vicary avatar vicary commented on July 30, 2024

Interesting enough I just came across an issue that might be related to this.

from knockout-sortable.

rniemeyer avatar rniemeyer commented on July 30, 2024

I think that this is definitely something that should be fixed. I will have to look into it a bit. The sourceIndex that is currently available is retrieved by using indexOf, which will just find the first one when dealing with primitives. I will need to hook into the "start" event and try to determine the index of the original element that is being dragged.

from knockout-sortable.

kicsiede avatar kicsiede commented on July 30, 2024

please note that if the array contains observable values, after drop the whole array will be wiped out. i think you should not make any assumptions on the array values but move (remove/insert) them by index.

from knockout-sortable.

rniemeyer avatar rniemeyer commented on July 30, 2024

@kicsiede - I agree, if I can get the appropriate index, then I will definitely move away from using remove.

from knockout-sortable.

cuu508 avatar cuu508 commented on July 30, 2024

Thanks for this.
A small problem: if you run this fiddle http://jsfiddle.net/rniemeyer/AC49j/ with current knockout-sortable.js you'll see it throws an error.

from knockout-sortable.

kicsiede avatar kicsiede commented on July 30, 2024

unfortunately you are still making assumptions on the values in several places
see this fiddle: http://jsfiddle.net/fnxaY/
the problem is at
2f2ea98#L0R140
2f2ea98#L0R161
that i could spot, you make decisions based on the falsiness of the value.
(2f2ea98#L0R70 this can also cause a problem)

from knockout-sortable.

rniemeyer avatar rniemeyer commented on July 30, 2024

@cuu508 - there was an issue with draggables, as they don't have a source array. This is fixed. I updated the fiddle with the latest files.

from knockout-sortable.

rniemeyer avatar rniemeyer commented on July 30, 2024

@kicsiede - looks like there is a bit more work to do to properly support falsey values (0, false, null, undefined, NaN, ""). I have an idea of how to handle it though. Going to open a separate issue for it.

from knockout-sortable.

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.