[英]jQuery UI Draggable - need to modify element while dragging
I'm playing with Drag and drop funcitonality for the first time so I'm not entirely sure what I'm doing!我第一次玩拖放功能,所以我不完全确定我在做什么!
I need to add a class to a "portlet" while it is being dragged.我需要在拖动时将 class 添加到“portlet”。 I don't want to use the clone functionality because I want the user to drag the actual element, I just want to nodify the element while it is being dragged and reset it when it's dropped.
我不想使用克隆功能,因为我希望用户拖动实际元素,我只想在拖动元素时对元素进行 nodify,并在删除元素时将其重置。
Can anybody help?有人可以帮忙吗?
Perhaps there's some sort of a ' beforedrag ' event you can bind to?也许您可以绑定某种“ beforedrag ”事件? It would be easier to add the class to an element before the user actually starts dragging it, rather than during.
将 class 添加到元素之前会更容易,而不是在用户实际开始拖动它之前。
If you're using jQuery UI, there's a ' start ' event on draggable you can use:如果您使用的是 jQuery UI,您可以使用可拖动的“开始”事件:
http://docs.jquery.com/UI/Draggable#events http://docs.jquery.com/UI/Draggable#events
Also, you can use the "helper" option like this:此外,您可以像这样使用“助手”选项:
helper : function(ev, el) {
return ($(el).clone().addClass("beingDragged"));
}
Should your portlets become in the future too heavyweight to drag, you could use that to build a simplified version while dragging to smooth things out:)如果您的 portlet 将来变得太重而无法拖动,您可以使用它来构建简化版本,同时拖动以使事情变得顺畅:)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.