How to automate angular-drag-and-drop-lists

2019-01-29 12:44发布

Problem : trying to simulate drag drop in frontend that uses angular-drag-and-drop-lists (go to detailed description)

Tried :

1.jquery-simulate: Gives following error

Uncaught TypeError: Failed to execute 'dispatchEvent' on 'EventTarget': parameter 1 is not of type 'Event'.

2.drag-drop-helper.js : click happens on item to be dragged

3.drag_to : nothing happens

Need some more suggestions .

Thanks

jquery-simulate: http://%20https://github.com/jquery/jquery-simulate

sorry not able to post link for drag_to and drag-drop-helper.js

1条回答
对你真心纯属浪费
2楼-- · 2019-01-29 13:49

Custom event needed to adjusted like this :

  function createCustomEvent(type) {
 var event = new CustomEvent("CustomEvent", {"cancelable": true})
    event.initCustomEvent(type, true, true, null);
    event.dataTransfer = {
        data: {
        },
        setData: function(type,val) {
            this.data[type] = val
            this.types[0] = type
        }
        getData: function(type) {
            return this.data[type]
        },
        dropEffect: 'move',
        effectAllowed:'move',
        types: [],
        items: {},
        files:{}

    }

    return event
}

in native js drag drop script and then it works fine

查看更多
登录 后发表回答