有誰知道如何結合jQuery UI可選和排序嗎? 此腳本:http://nicolas.rudas.info/jquery/selectables_sortables/在Chrome中不起作用,並且還具有插件修改。jQuery UI可排序和可選
28
A
回答
32
剛剛發現this很容易的解決方案,從rdworth:
CSS:
ul { width: 300px; list-style: none; margin: 0; padding: 0; }
li { background: white; position:relative;margin: 1em 0; padding: 1em; border: 2px solid gray; list-style: none; padding-left: 42px; }
li .handle { background: #f8f8f8; position: absolute; left: 0; top: 0; bottom: 0; padding:8px; }
.ui-selecting { background: #eee; }
.ui-selecting .handle { background: #ddd; }
.ui-selected { background: #def; }
.ui-selected .handle { background: #cde; }
HTML:
<ul id="list">
<li>Item 1</li>
<li>Item 2</li>
<li>Item 3</li>
<li>Item 4</li>
<li>Item 5</li>
</ul>
的Javascript:
$("#list")
.sortable({ handle: ".handle" })
.selectable({ filter: "li", cancel: ".handle" })
.find("li")
.addClass("ui-corner-all")
.prepend("<div class='handle'><span class='ui-icon ui-icon-carat-2-n-s'></span></div>");
參見:this小提琴。
5
這是像我可以給ü:)但這個想法是存在的。它不是alllll完成,但希望美國可以發揮一下的價值觀,看看它是從那裏怎麼一回事呢:)我的jQuery基庫的
0
部分包括以下內容,因爲它是通常討厭當你去拖東西,最終不是選擇文本...
// disables text selection on sortable, draggable items
$(".sortable").sortable();
$(".sortable").disableSelection();
不知道如果你可以翻轉「禁用」爲「Enable」,但有我的$ .02。雖然沒有嘗試過......常識意味着你可能需要在同一個「group」元素中定義一個非活動部分,爲拖動動作提供一個「句柄......」,否則這些點擊可能被無情地誤認爲是意圖選擇/編輯...
0
試試這個。您可以使用Ctrl + Click
多選擇和排序
+0
請在答案本身中添加代碼的相關部分... – 2016-07-01 09:50:19
0
如果要選擇多個元素和MOVE他們全都另一份清單,這fiddle效果很好:
HTML:
<meta charset="utf-8" />
<title>jQuery UI Sortable with Selectable</title>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<body>
<ul id="album" class="connectedSortable">
<li id="li1"><div>1- First</div></li>
<li id="li2"><div>2- Second</div></li>
<li id="li3"><div>3- Third</div></li>
<li id="li4"><div>4- Fourth</div></li>
<li id="li5"><div>5- Fifth</div></li>
<li id="li6"><div>6- Sixth</div></li>
<li id="li7"><div>7- Seventh</div></li>
<li id="li8"><div>8- Eighth</div></li>
</ul>
<ul id="album2" class="connectedSortable">
<li id="li1"><div>1- 1</div></li>
<li id="li2"><div>2- 2</div></li>
<li id="li3"><div>3- 3</div></li>
<li id="li4"><div>4- 4</div></li>
<li id="li5"><div>5- 5</div></li>
<li id="li6"><div>6- 6</div></li>
<li id="li7"><div>7- 7</div></li>
<li id="li8"><div>8- 8</div></li>
</ul>
<div id="anotheralbum" class="connectedSortable">
another album - no style for the lists inside here
</div>
<br style="clear:both">
</body>
Javascript:
<script>
$(function() {
//
$('body').selectable({
filter: 'li'
//filter: '#album2 > li'
});
/*
Since the sortable seems unable to move more than one object at a
time, we'll do this:
The LIs should act only as wrappers for DIVs.
When sorting a LI, move all the DIVs that are children of selected
LIs to inside the sorting LI (this will make them move together);
but before doing that, save inside the DIVs a reference to their
respective original parents, so we can restore them later.
When the user drop the sorting, restore the DIVs to their original
parent LIs and place those LIs right after the just-dropped LI.
Voilá!
Tip: doesn't work so great if you try to stick the LIs inside the LI
*/
$('.connectedSortable').sortable({
connectWith: ".connectedSortable",
delay: 100,
start: function(e, ui) {
var topleft = 0;
// if the current sorting LI is not selected, select
$(ui.item).addClass('ui-selected');
$('.ui-selected div').each(function() {
// save reference to original parent
var originalParent = $(this).parent()[0];
$(this).data('origin', originalParent);
// position each DIV in cascade
$(this).css('position', 'absolute');
$(this).css('top', topleft);
$(this).css('left', topleft);
topleft += 20;
}).appendTo(ui.item); // glue them all inside current sorting LI
},
stop: function(e, ui) {
$(ui.item).children().each(function() {
// restore all the DIVs in the sorting LI to their original parents
var originalParent = $(this).data('origin');
$(this).appendTo(originalParent);
// remove the cascade positioning
$(this).css('position', '');
$(this).css('top', '');
$(this).css('left', '');
});
// put the selected LIs after the just-dropped sorting LI
$('#album .ui-selected').insertAfter(ui.item);
// put the selected LIs after the just-dropped sorting LI
$('#album2 .ui-selected').insertAfter(ui.item);
}
});
//
});
</script>
CSS:
<style>
*,
*:before,
*:after {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
#album {
list-style: none;
float: left;
width: 20%;
border: 1px solid red;
}
#album2 {
list-style: none;
float: left;
width: 20%;
border: 1px solid red;
}
#album li {
float: left;
margin: 5px;
}
#album2 li {
float: left;
margin: 5px;
}
#album div {
width: 100px;
height: 100px;
border: 1px solid #CCC;
background: #F6F6F6;
}
#album2 div {
width: 100px;
height: 100px;
border: 1px solid #CCC;
background: #F6F6F6;
}
#album .ui-sortable-placeholder {
border: 1px dashed #CCC;
width: 100px;
height: 100px;
background: none;
visibility: visible !important;
}
#album2 .ui-sortable-placeholder {
border: 1px dashed #CCC;
width: 100px;
height: 100px;
background: none;
visibility: visible !important;
}
#album .ui-selecting div,
#album .ui-selected div {
background-color: #3C6;
}
#album2 .ui-selecting div,
#album2 .ui-selected div {
background-color: #3C6;
}
#anotheralbum {
list-style: none;
float: left;
width: 20%;
height: 800px;
border: 1px solid blue;
}
</style>
這是從例如在http://www.pieromori.com.br/snippets/sortable_with_selectable.html感謝皮耶羅森修改。
相關問題
- 1. Jquery UI可排序
- 2. jQuery UI可排序:多項選擇
- 3. jQuery UI可以選擇框排序
- 4. jQuery UI可排序問題
- 5. jQuery UI可排序位置
- 6. jQuery UI可排序公差
- 7. jQuery UI可排序和對話
- 8. jQuery UI可排序和容器縮放
- 9. 使用jQuery UI可拖動,可放開和可排序
- 10. jQuery UI可拖動connectToSortable不遵守可排序項選項
- 11. 編輯可排序的可選li與jquery-ui
- 12. 內置可排序列表的JQuery UI可排序部分(div)
- 13. jQuery可選擇句柄和排序
- 14. JQuery可排序/可選插件與drag'n'drop?
- 15. jQuery多選可拖拽/可排序
- 16. 通過jQuery的UI可排序變量
- 17. IE7的JQuery UI可排序的問題
- 18. 使用jQuery UI的Knockoutjs可排序
- 19. jQuery UI可排序表句柄
- 20. jQuery UI:如何保存「可排序」?
- 21. 替代jQuery ui可排序需要
- 22. JQuery UI可排序按鈕集
- 23. jQuery UI可排序的動畫轉換
- 24. jQuery UI可排序窗口滾動
- 25. jQuery可排序UI語法問題
- 26. jQuery UI的可排序的子觸發
- 27. jQuery UI中的循環項可排序
- 28. jQuery UI可排序固定行
- 29. JQuery UI可排序 - ConnectWith - 禁用一列
- 30. JQUERY UI可排序居中元素
我已經做到了,但由於一些版權問題,我沒有給出代碼:),但我會告訴你如何的指導:) – Val 2011-02-23 13:06:19