rniemeyer / knockout-sortable

A Knockout.js binding to connect observableArrays with jQuery UI sortable functionality
MIT License
547 stars 128 forks source link

Implementing receive callback for sortables #119

Closed igitur closed 9 years ago

igitur commented 9 years ago

Hi,

I want to implement something similar to http://codepen.io/mj_azani/pen/npohF in a knockout sortable to choose which items are to be accepted. I've tried passing through a receive event in the sortable's jQuery UI options, but the callback is never executed.

Digging into the source, it seems the receive event is triggered only for pure draggables and not for sortables too, but I might be wrong.

igitur commented 9 years ago

I'm happy to submit a PR to fix this if I can just get some clarity on the current rationale.

rniemeyer commented 9 years ago

@igitur - I believe that I used receive because I need a hook to process the drag item before it got to the "normal" processing. Have you looked at the beforeMove callback that the sortable binding provides? Would look something like this: http://jsfiddle.net/rniemeyer/0h3ufbee/

rniemeyer commented 9 years ago

I believe that the beforeMove callback would be the best choice for what you want. Please re-open, if I did not understand your scenario.

igitur commented 9 years ago

Sorry, on holiday at the moment. I'll look at the jsfiddle when I get back. Thanks.

rniemeyer commented 9 years ago

@igitur - no problem, definitely post back here, if you can't get it to work. Thanks!