【发布时间】:2017-10-22 19:31:47
【问题描述】:
我正在尝试使用 dojo 创建一个拖放列表。拖放工作正常,但是当我在触发 DndDrop、DragStart 和使用 dojo/query 和 dojo 的拖放相关的类似事件后尝试编写任何功能时/on...event 未处理。Again..click 事件为同一个 NodeList 工作正常。请指出我的错误。
<!DOCTYPE html>
<html>
<head>
<title>clac</title>
<link rel="stylesheet" type="text/css" href="calcdojo.css">
</head>
<body>
<ul>
<li id="operand1" class="container dropArea"></li>
<li id="operator1" class=" container dropArea"></li>
<li id="operand2" class=" container dropArea"></li>
<li id="result"></li>
</ul>
<ul id="sourcelist" class="container">
</ul>
<script src="https://ajax.googleapis.com/ajax/libs/dojo/1.12.2/dojo/dojo.js"></script>
<script type="text/javascript">
require(["dojo/dom-style","dojo/dom-construct","dojo/dnd/Source","dojo/dnd/Source","dojo/query","dojo/on","dojo/domReady!"],function(domStyle,domConstruct,Source,Source,query,on){
var sourcelist = new Source('sourcelist',{accept:[""]});
sourcelist.copyOnly = true;
sourcelist.insertNodes(false,[
{data: "1",type:["operand"]},
{data: "2",type:["operand"]},
{data: "3",type:["operand"]},
{data: "+",type:["operator"]}]);
var operand1 = new Source('operand1',{accept:["operand"]});
var operand2 = new Source('operand2',{accept:["operand"]});
var operator1 = new Source('operator1',{accept:["operator"]});
var dropArea = query(".dropArea");
dropArea.on("DndDrop",function(event){
event.preventDefault();
console.log("dropped");
});
});
</script>
</body>
</html>
(我这里需要显示“dropped”)
【问题讨论】:
-
有错误可以分享吗?此外,您想显示“dropped”,但在此之前,您将停止事件,那么 console.log("dropped") 将如何执行?
-
我很抱歉这个错误...我现在已经编辑了代码。并且没有显示错误。
标签: javascript dojo