Hello :-)
Is there a way to deselect the selected items after grabbing them and dropping them on their new position? At the moment, the user has to deselect everything after dragging.
Thanks
@reicheltmediadesign Something like this:
new Sortable(el, {
onEnd: function(evt) {
for (let i in evt.items) {
Sortable.utils.deselect(evt.items[i]);
}
}
});
Let me know if this solves it for you.
@owen-m1 no, doesn't change anything.
I currently have this:
var Sortable = new Sortable(el, {
multiDrag: true, selectedClass: 'selected', animation: 150, onDrop: function(evt) { for (let i in evt,items) { console.log(evt.items[i]); Sortable.utils.deselect(evt.items[i]); } } })
It doesn't even log anything in console window (I added this line for testing purposes)
@reicheltmediadesign My bad.. it is actually the onEnd event, not onDrop.
Here is a working JSBin: https://jsbin.com/merayer/4/edit?js,output
@owen-m1 after I changed from onDrop to onEnd now it says in console:
(index):150 Uncaught TypeError: Cannot read property 'deselect' of undefined
at Sortable.onEnd ((index):150)
at dispatchEvent (Sortable.js:909)
at _dispatchEvent (Sortable.js:954)
at Sortable._onDrop (Sortable.js:2202)
at Sortable.handleEvent (Sortable.js:2231)
@reicheltmediadesign Sorry, the JSBin link wasn't saving properly. JSBin should work now.
If you are getting that error, could you try to reproduce it in a JSBin? Sortable.utils should always be defined.
@owen-m1 Interesting, I 'copied' your example to my application and now it works like a charm. Thank you very! much, you saved me hours if trying to get this to work.
Most helpful comment
@reicheltmediadesign Sorry, the JSBin link wasn't saving properly. JSBin should work now.
If you are getting that error, could you try to reproduce it in a JSBin? Sortable.utils should always be defined.