如何自动化角度拖放列表 [英] How to automate angular-drag-and-drop-lists
问题描述
问题: 尝试在使用 angular-drag-and-drop-lists (转到详细说明)
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
未捕获的类型错误:无法执行 'dispatchEvent'EventTarget":参数 1 不是事件"类型.
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:https://github.com/jquery/jquery-simulate
jquery-simulate: https://github.com/jquery/jquery-simulate
抱歉不能发布drag_to 和drag-drop-helper.js 的链接
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
}
在 本机 js 拖放脚本然后它工作正常
这篇关于如何自动化角度拖放列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!