Jquery UI - 从显示中获取一个元素:拖动时隐藏元素 [英] Jquery UI - Getting one element out of a display:hidden element when dragging

查看:97
本文介绍了Jquery UI - 从显示中获取一个元素:拖动时隐藏元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一组元素位于另一个设置溢出的元素中的'conveyor'元素上:使用css隐藏。拖动时,如何将溢出设置为隐藏的holder元素的元素out?当我拖动item分类图像时,它只会在支架内拖动,当我尝试将其移动到支架外部时,它会隐藏,并且不会移动到旧支架元素之外。

I have a group of elements sitting on a 'conveyor' element within another element that is set overflow:hidden using css. How do I, when dragging, get the element 'out' of the holder element that has overflow set to hidden? When I drag the "item" classed image, it only drags within the holder, when I try to move it "outside" the holder, it hides, and won't move outside the old holder element.

<div class="holder" style="overflow:hidden;">
     <div class="conveyor">
          <img src="image1.jpg" class="item" />
          <img src="image2.jpg" class="item" />
          <img src="image3.jpg" class="item" />
     </div>
</div>

<script>

     $('.item').draggable();

</script>

我还尝试将新移动的元素追加到父元素,但随后赢得了项目请回复我的持有人....请帮助!

I've also tried to append the newly moved element to a parent element, but then the item won't revert back to my holder.... please help!

尝试附加项目:

$('.item').draggable(
     helper:'clone';
     revert:'invalid',
     start:function(){
          $(this).parent().parent().append(this);
     }
)


推荐答案

在这里找到答案 - > http://docs.jquery.com/UI/Draggable 。 Yeesh ......这是几个小时的挖掘!

Found the answer here -> http://docs.jquery.com/UI/Draggable. Yeesh... that was a few hours of digging!

传递给appendTo选项或由其选择的元素将在拖动过程中用作可拖动帮助器的容器。默认情况下,帮助程序将附加到与draggable相同的容器中。

The element passed to or selected by the appendTo option will be used as the draggable helper's container during dragging. By default, the helper is appended to the same container as the draggable.

$('.selector').draggable({ appendTo: 'body' });

感谢您的帮助!

这篇关于Jquery UI - 从显示中获取一个元素:拖动时隐藏元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆