dojo 拖放:如何为放置事件添加处理程序
我有一个像这样的简单列表:
<div dojoType="dojo.dnd.Source" id="myList">
<div class="dojoDndItem">item 1</div>
<div class="dojoDndItem">item 2</div>
<div class="dojoDndItem">item 3</div>
</div>
我使用 dojo 属性使列表可排序。
它的工作没有任何问题,但如何在项目被删除时向事件添加侦听器?如果用户释放鼠标并且元素捕捉到位,我需要一个 javascript 函数来处理此事件。如何通过标记添加它?
I have a simple list like this:
<div dojoType="dojo.dnd.Source" id="myList">
<div class="dojoDndItem">item 1</div>
<div class="dojoDndItem">item 2</div>
<div class="dojoDndItem">item 3</div>
</div>
And I use the dojo attributes to make the list sortable.
It works without any problems, but how do I add a listener to the event when an item is dropped? If the user releases the mouse and the element snaps in place I want a javascript function to handle this event. How can I add it via markup?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可能感兴趣的扩展点是 Source 上的
onDrop
方法。您可以使用解析器理解的语法以声明方式完成此操作,例如:
请注意,我连接到方法,因为
dojo.dnd.Source
的onDrop
方法及其在默认实现中调用的方法中有重要的功能;如果我使用来覆盖该函数,则默认功能将被破坏。
以下 SitePen 博客文章提供了有关解析器中可用的此功能的更多信息: http://www.sitepen.com/blog/2007/09/21/dojo-09-power-tools-script-typedojomethod/
The extension point you're probably interested in is the
onDrop
method on the Source. You can use the<script type="dojo/...">
syntax understood by the parser to accomplish this declaratively, e.g.:Note that I connect to the method because there is important functionality within
dojo.dnd.Source
'sonDrop
method, and the methods it invokes in its default implementation; if I were to override the function instead by using<script type="dojo/method">
, that default functionality would be clobbered.The following SitePen Blog post gives more information on this feature available in the parser: http://www.sitepen.com/blog/2007/09/21/dojo-09-power-tools-script-typedojomethod/