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

落花浮王杯 提交于 2019-12-18 09:42:31

问题


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: https://github.com/jquery/jquery-simulate

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


回答1:


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



来源:https://stackoverflow.com/questions/43109946/how-to-automate-angular-drag-and-drop-lists

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!