jQuery UI 可排序 &可选择的 [英] jQuery UI sortable & selectable

查看:19
本文介绍了jQuery UI 可排序 &可选择的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有谁知道如何结合 jQuery UI 可选择和可排序?这个脚本:http://nicolas.rudas.info/jquery/selectables_sortables/t 在 Chrome 中工作,它也有插件修改.

Does anybody know how to combine jQuery UI selectable and sortable ? This script: http://nicolas.rudas.info/jquery/selectables_sortables/ doesn't work in Chrome and it also has plugin modifications.

推荐答案

刚发现 这个来自rdworth的非常简单的解决方案:

Just found this very easy solution from 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:

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>" );

参见:这个小提琴.

这篇关于jQuery UI 可排序 &amp;可选择的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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