1

我想通过将列表项放在适当的选项卡上来移动元素。我使用 Simon Battersby 的解决方案,在列表中添加一个风格化的滚动条: Vertical Scrollbar Plugin using jQueryUI Slider。我使用以下解决方案来解决当您在屏幕上拖动时列表项是否可见: jQuery Draggable and overflow issue

我的示例是http://jsfiddle.net/XmahV/

当可排序选项中的 helper="original" 时,以下代码有效:

drop: function( event, ui ) {
   var $tabItem = $( this );
   var $list = $( $tabItem.find( "a" ).attr( "href" ) ).find( ".sortable" );

   **ui.draggable.hide( "slow", function() {
   $(this).appendTo($list).show();//it does not work in my case
   });**              

}

但在我的情况下 helper="clone":

$( ".sortable" ).sortable({
                    connectWith: ".sortable",
                    //Need to drag across the entire window. Overflow issue.
                    appendTo: "body",  
                    containment: "window",
                    scroll: false,
                    helper: "clone"
                    //End Overflow issue.
        });

降低标签标题时,有人可以帮我移动列表项吗?或者有人可以告诉我,当您将项目转移到选项卡的标题时,如何从列表中删除项目?

谢谢

4

1 回答 1

0

事实上,在使用“克隆”选项的情况下,原始元素会被隐藏。因此,您不能重新隐藏已经隐藏的元素......这就是它不起作用的原因。我刚刚在您的代码之前显示了原始元素:http: //jsfiddle.net/XmahV/4/

var $tab_items = $("ul:first li", $tabs).droppable({
  accept: ".sortable .dragItem",
  hoverClass: "ui-state-hover",
  start: function (event, ui) {},
  stop: function (event, ui) {},
  receive: function (event, ui) {},

  drop: function (event, ui) {
    var $tabItem = $(this);
    var $list = $($tabItem.find("a").attr("href")).find(".sortable");

    //In case of clone helper, you must force to display the original element before hide it
    ui.draggable.show();
    ui.draggable.hide("slow", function () {
      $(this).appendTo($list).show();
    });

  }
于 2013-01-11T07:46:21.617 回答