Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sorting problem #12

Open
guillome2k opened this issue Jul 12, 2018 · 6 comments
Open

Sorting problem #12

guillome2k opened this issue Jul 12, 2018 · 6 comments

Comments

@guillome2k
Copy link

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

@Insinfi
Copy link

Insinfi commented Aug 21, 2018

I have the same probleme have you found any fix ?

@guillome2k
Copy link
Author

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

@Insinfi
Copy link

Insinfi commented Aug 21, 2018

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

@guillome2k
Copy link
Author

guillome2k commented Aug 21, 2018

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(); }

@Insinfi
Copy link

Insinfi commented Aug 21, 2018

Ok perfect thanks you saved me a bunch of hours

@guillome2k
Copy link
Author

Yw :) success!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants