bosket
bosket copied to clipboard
Drag and Drop not working on IE 11
this.pluckPreset.drag(target, event, inputs);
ERROR Error: Unexpected call to method or property access.
this.pluckPreset.drop(target, event, inputs);
ERROR TypeError: Object doesn't support property or method 'indexOf'
It looks like during drag
event.dataTransfer.setData("application/json", JSON.stringify(item))
The first argument must be "Text" instead of "applicaiton/json".
I did this to fix it.
pluck: function pluck(model, cb) {
return {
draggable: true,
backup: [],
drag: function drag(item, event, inputs) {
bak = JSON.stringify(model());
let isIE = false || !!document.documentMode;
let dataType='application/json';
if(isIE){
dataType='Text'
}
event.dataTransfer && event.dataTransfer.setData(dataType, JSON.stringify(item));
setTimeout(function () {
return cb(tree(model(), inputs.category).filter(function (e) {
return e !== item;
}));
}, 20);
},
cancel: function cancel() {
cb(JSON.parse(bak));
}
};
},
// Pastes item(s) on drop
paste: function paste(model, cb) {
return {
droppable: true,
drop: function drop(target, event, inputs) {
let isIE = false || !!document.documentMode;
let dataType='application/json';
let dataTransferCond=false;
if(isIE){
dataType='Text'
dataTransferCond=event.dataTransfer && event.dataTransfer.types.contains(dataType)
}
else{
dataTransferCond=event.dataTransfer && event.dataTransfer.types.indexOf(dataType) !== -1;
}