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

Allow or document use of Sortable events #11

Closed
Prakkus opened this issue Aug 19, 2016 · 12 comments
Closed

Allow or document use of Sortable events #11

Prakkus opened this issue Aug 19, 2016 · 12 comments

Comments

@Prakkus
Copy link

Prakkus commented Aug 19, 2016

I'm trying to set up my Sortable options like so:
sortableOptions: { draggable : ".list-item", onUpdate : function() { console.log('updated!'); } }
The onUpdate doesn't trigger though, since your version of the function overrides it during your _merge.

Is there a different way you suggest me hooking into that event so that I can also use it to execute some code? Or can it be updated to call your function, then the one passed through in an option?

Thanks!

@David-Desmaisons
Copy link
Member

Hi @logust , I would suggest that you watch directly the change events on the underlying Vm collection using vuejs watch API. This should cover the scenario you want to address. Please tell me if that would work for you and if not, please explain what you want to achieve. Thanks.

@Prakkus
Copy link
Author

Prakkus commented Aug 19, 2016

Ah, of course. That approach is probably better anyway.

I would maybe just add a bit in the documentation that says something like "Normally you would hook into Sortable events using the options, but instead you should use vue's watch API like so simple example here".

Maybe not worth doing if I'm the only person who couldn't figure it out though :)

@David-Desmaisons
Copy link
Member

Hi @logust , you are rigth: I will update the documentation and then close the issue.

@David-Desmaisons
Copy link
Member

Documentation updated

@lukepolo
Copy link

@David-Desmaisons I have an issue where I have 1 list that is in a bucket with a particular order , and the other that doesn't matter the order.

So I need the ability to sort list1 when list1 changes. Which means i cannot use the watch method because it will have a loop.

Ideas how to get around this?

@David-Desmaisons
Copy link
Member

@lukepolo please open another issue with a jsfiddle descibing what you want to achieve and what is the problem. Thanks.

@lukepolo
Copy link

lukepolo commented Nov 18, 2016

Here is my jsfiddle

https://jsfiddle.net/jyf2fuwj/4/

Im trying to make sure the list 1 is in the proper order

@David-Desmaisons
Copy link
Member

You can use sort:false as option on the list that should not be reordered: https://jsfiddle.net/dede89/4amr9hdp/.
Is that the behaviour you want:

@lukepolo
Copy link

lukepolo commented Nov 18, 2016

No sorry ill try to explain it better.

Each entry in my list has a property called order , this dictates the order, the items must be displayed.

When someone drags from a item from list 2 to list 1 , list 1 then reorders based on their order property

@lukepolo
Copy link

Also list 2 does not care of the order of its items.

@David-Desmaisons
Copy link
Member

  1. observe event linked to drag and drop not underlying collection
  2. use next tick to avoid the loop

Here:

https://jsfiddle.net/dede89/4amr9hdp/

@lukepolo
Copy link

Ah your awesome thank you

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

3 participants