Skip to content

Sorting problem #12

Open
Open

Description

@guillome2k

Hi,

Thanks for this wonderfull binding.
Only, the following line makes the sorting go wrong when i sort down:

if (e.item.previousElementSibling) { // Uit want foute sorting
     newIndex = to().indexOf(ko.dataFor(e.item.previousElementSibling)) + 1;
}

http://jsfiddle.net/wgv76t25/36

Activity

  1. Insinfi commented on Aug 21, 2018

    @Insinfi

    I have the same probleme have you found any fix ?

  2. guillome2k commented on Aug 21, 2018

    @guillome2k
    Author

    I made a couple of changes for my project and is working very nice

  3. Insinfi commented on Aug 21, 2018

    @Insinfi

    May I ask you to share what you have done please ?

  4. guillome2k commented on Aug 21, 2018

    @guillome2k
    Author

    Ok, i dont remember exactly what was for my project specific or not.

    1. Line 87, added:
    if (options.onCreate) { 
            	options.onCreate(sortableElement);
            }
    
    1. Line 142, changed:
      if (e.item.previousElementSibling && from !== to) {

    2. Line 156, changed:
      if (!ko.isComputed(from)) { from.valueHasMutated(); }

    3. Line 162, changed:
      if (!ko.isComputed(from)) { from.valueHasMutated(); }

    4. Line 163-167 changed:
      if (from === to) { // Aanpassing WTG // Insert the item on its new position to().splice(newIndex, 0, itemVM); // Make sure to tell knockout that we've modified the actual array. to.valueHasMutated(); }

  5. Insinfi commented on Aug 21, 2018

    @Insinfi

    Ok perfect thanks you saved me a bunch of hours

  6. guillome2k commented on Aug 21, 2018

    @guillome2k
    Author

    Yw :) success!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions