2015-01-16 183 views
3

我有jQuery Ui可拖动元素的样式问题。 这里我有什么jQuery ui可拖动元素获取其他可拖动元素

FIDDLE

就像你看到的,我有两个可投放区域,在每个区域中的元素都是可拖动,并可以将它从一个块放入,元素到另一个 唯一的问题,即当我将元素从顶部块拖动到块下面时,拖动元素在可拖放元素下面是元素,但是当我从底部拖动到顶部时,不存在这样的问题。

这里是拖动

$(".slide").draggable({ 
    // brings the item back to its place when dragging is over 
    revert:true, 
    // once the dragging starts, we decrease the opactiy of other items 
    // Appending a class as we do that with CSS 
    start: function(event, ui) { $(this).css("z-index", a++); }, 
    drag:function() { 
     $(this).removeClass('droped'); 
    }, 
    // adding the CSS classes once dragging is over. 
    stop:function() { 
     $(this).addClass('droped'); 
    }, 
    zIndex: 10000, 
    snapMode: "inner" 
}); 

任何人可以帮助我,请我的工作,它已经2天的代码,并不能弄清楚是什么问题,我已经试图改变Z-每个块的索引位置,但没有结果;

+0

你拨弄不工作,但你可以尝试给的z-index你试图移动,也许您在下面想要的块太大 – Randy

+0

删除'Z-索引:来自'ul.book_list'的[2] [小提琴](http://jsfiddle.net/sameer_kc/zbo7g5nz/3/) – Sami

+0

请不要绕开质量过滤器。这不是你的第一个问题,[你之前直接在代码中包含代码](http://stackoverflow.com/questions/27633120/website-with-scrollmagic-pins)。 – BoltClock

回答

2

我发现我的代码只工作的第一次 - 我删除了您JQuery的一些Z-索引和你的CSS,现在它每一次为我工作:

http://jsfiddle.net/zbo7g5nz/5/


我jFiddle似乎没有得到更新,分享。这里是工作代码:

$(".slide").draggable({ 
     // brings the item back to its place when dragging is over 
     revert:true, 
     // once the dragging starts, we decrease the opactiy of other items 
     // Appending a class as we do that with CSS 
     start: function(event, ui) { $(this).css("z-index", a++); }, 
     drag:function() { 
      $(this).parent().css('z-index', '10001'); 
      $(this).removeClass('droped'); 
     }, 
     // removing the CSS classes once dragging is over. 
     stop:function() { 
      $(this).parent().css('z-index', '10001'); 
      $(this).addClass('droped'); 
     }, 
     zIndex: 10000, 
     snapMode: "inner" 
    }); 

我给的z-index到ul持有li比下面列表中的li高。

+0

tnx,但ul有z-index:2已经设置,我找不到你有什么改变,请它你已经解决和工作的小提琴,如果更新,如果请给我,TNN –

+0

非常感谢,是工作,伟大,ü救救我:) –

1

避免诡计,并使用div而不是UL或LI来进一步兼容。

另外,您不需要侦听启动事件来设置z-index属性。 .draggable()api公开了zIndex prop

Here is the demo working: 

http://jsfiddle.net/zbo7g5nz/8/

+0

你确实有点违反拖放,你有没有注意到? – Randy

+0

请不要仅因为提问者也这样做而绕开质量过滤器。链接意味着被点击。 – BoltClock

+0

@randy是的,我注意到,但它只是清楚:都在CSS上。删除它,你有它的工作;) – Lothre1