如何自动化角拖放列表 [英] How to automate angular-drag-and-drop-lists

查看:188
本文介绍了如何自动化角拖放列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问题:试图模拟前端使用角度拖放列表的拖放(详细描述

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

试过:

1.jquery-simulate:提供以下错误

1.jquery-simulate: Gives following error


未捕获TypeError:无法在
'EventTarget'上执行'dispatchEvent':参数1不是Event类型。

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

2.drag-drop-helper.js:点击发生在要拖动的项目上

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

3.drag_to:没有发生

3.drag_to : nothing happens

需要更多建议。

谢谢

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

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

抱歉不能po用于drag_to和drag-drop-helper.js的st链接

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

推荐答案

自定义事件需要如下调整:

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
}

native js拖放脚本,然后它工作正常

这篇关于如何自动化角拖放列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆