[v2] sortable:sort event not firing


#1

Just moved to V2 and the sortable:sort event isn’t firing. I’ve tried attaching the listener at both the list level (where it used to be) and the <li> level (as stated in the docs), but nothing.

The only thing that works is app.on('sortableSort', function(listEl, indexes) {...handler...}), but that’s global for any sortable, so my event handler would need to handle all sortables in the app…that’s not good.

Question is, in V2, how/where to attach a listener for sortable:sort on a particular list?


#2

I’m either an idiot or it’s been fixed. Probably the former. Now attaching a listener to the li works as stated in the docs, though in my case, the index changes are inside event.originalEvent.detail

$('.sortable li').on('sortable:sort', function(event){
    var from = event.originalEvent.detail.from;
    var to = event.originalEvent.detail.to;
    if (from != to) {
        handleItemSort(from, to);
    } 
});

#3

This is because of jQuery, it is proxying events and move origin event to originalEvent