Skip to content
This repository has been archived by the owner on Dec 7, 2019. It is now read-only.

Drag and Drop not working on IE 11 #47

Open
jmoseman01 opened this issue Jul 9, 2018 · 2 comments
Open

Drag and Drop not working on IE 11 #47

jmoseman01 opened this issue Jul 9, 2018 · 2 comments

Comments

@jmoseman01
Copy link

jmoseman01 commented Jul 9, 2018

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'

@jmoseman01
Copy link
Author

jmoseman01 commented Jul 9, 2018

It looks like during drag
event.dataTransfer.setData("application/json", JSON.stringify(item))
The first argument must be "Text" instead of "applicaiton/json".

@jmoseman01
Copy link
Author

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;
                }

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant