thgreasi / ui-sortable-multiselection

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

$watch vs stop() callback run sequence #24

Closed insmark closed 8 years ago

insmark commented 8 years ago

I try to convert this connected list to the multiselection list. When I select multiple items from right to left, it doesn't work at all, not sure if I did wrong or there is bug.

Here's the demo.

thgreasi commented 8 years ago

That's interesting... It seems right... I will investigate it.

thgreasi commented 8 years ago

The issue seems to be that the $watch runs before the stop callback, where the multi-item-selection actually moves the models from one list to an other. Here is a working sample-pen.

thgreasi commented 8 years ago

Feel free to re-open in any case.

insmark commented 8 years ago

Hi, thank you very much for the quick fix. I have another question. I add a button to find all the selected items from the left, then add to the right instead of drag and drop. How can I find all the selected items?

Here's the pen.

thgreasi commented 8 years ago

Here is a working codepen sample. Alternatively, you can listen for the ui-sortable-selectionschanged event one the parent element.

insmark commented 8 years ago

Thank you!

insmark commented 8 years ago

Hi, your codepen sample works find in Chrome and Firefox, but in IE11 got SCRIPT1002: Syntax error for the line "var selectedItems = $('.availableReportsBox .ui-sortable-selected').toArray().map(x => $(x).scope().listItem);", looks like the IE doesn't like the "=>".

thgreasi commented 8 years ago

I don't even remember using it... But it obviously got in there anyway. I guess you can easily change the arrow function expression to a plain anonymous function yourself function(x){...} .

insmark commented 8 years ago

It works fine change to "var selectedItems = $('.availableReportsBox .ui-sortable-selected').toArray().map(function (x) { return $(x).scope().listItem });", thanks.