thgreasi / ui-sortable-multiselection

Provide multiple element sorting in UI-Sortable
MIT License
30 stars 12 forks source link

Select events #13

Closed feus4177 closed 8 years ago

feus4177 commented 9 years ago

It would be nice if there were events for un/selecting elements. Currently I have a $watch that checks for the 'ui-sortable-selected' class but I would prefer to listen for an event.

thgreasi commented 9 years ago

Great idea :+1: I will add it to my to-do list.

thgreasi commented 8 years ago

How about an ui-sortable-selectionschanged on the ui-sortable element itself?

thgreasi commented 8 years ago

I would prefer it instead of firing several events on the selectable items (for selections and deselections).

thgreasi commented 8 years ago

15 is a sample solution.

feus4177 commented 8 years ago

That should be enough for my use case. I was thinking in general it might be nice to add information like which elements are selected. It would be nice if the event could be heard even when the element is immediately dragged but again that isn't critical for me. Would jquery-ui-sortable interfere with an angular $emit event?

thgreasi commented 8 years ago

Do you prefer emitting jquery events or using angular's $emit? Because, I think that $emit can lead to unnecessary digests.

feus4177 commented 8 years ago

Normally I try to stay within the confines of angular as much as possible and only use jquery for DOM traversal, but since the core of the functionality is still jquery-ui and all the other events are jquery events I'm fine with continuing to use jquery events. It's just unfortunate that sometimes the ui-sortable-selectionschanged event will be prevented but it isn't a huge deal.

thgreasi commented 8 years ago

This is partially fixed in #18 where we trigger the 'ui-sortable-selectionschanged' event on the ui-sortable element. There is currently no extra message passed along with the event. Please try it out and suggest improvements. For example we could trigger the event with the selected model indexes as a message.

pedro-mass commented 8 years ago

How can make use of that event to capture the elements selected? Do you have a code sample?