最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - jQuery UI Draggable - need to modify element while dragging - Stack Overflow

programmeradmin2浏览0评论

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. 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.

Can anybody help?

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. 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.

Can anybody help?

Share Improve this question asked Feb 24, 2009 at 17:51 jonhobbsjonhobbs 28k39 gold badges118 silver badges179 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 3

Perhaps there's some sort of a 'beforedrag' event you can bind to? It would be easier to add the class to an element before the user actually starts dragging it, rather than during.

If you're using jQuery UI, there's a 'start' event on draggable you can use:

http://docs.jquery./UI/Draggable#events

Also, you can use the "helper" option like this:

helper : function(ev, el) {
  return ($(el).clone().addClass("beingDragged"));
}

Should your portlets bee in the future too heavyweight to drag, you could use that to build a simplified version while dragging to smooth things out :)

发布评论

评论列表(0)

  1. 暂无评论