您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

jqueryUI里拖拽排序示例分析_jquery

2024/4/22 0:34:16发布12次查看
示例参考http://jsfiddle.net/kylemit/geupm/2/  (这个站需要fq才能看到效果)
其实是jqueryui官方购物车拖拽添加例子的增强版,就是在拖拽的时候增加了排序
这个是html代码
复制代码 代码如下:
products
t-shirts
lolcat shirt
            cheezeburger shirt
            buckit shirt
bags
zebra striped
            black leather
            alligator leather
gadgets
iphone
            ipod
            ipad
shopping cart
add your items here
这个是js代码主要在js代码中红色代码部分设置了可以拖动进入时就排序,橙色代码部分不太理解,好像没用的样子
复制代码 代码如下:
$(function () {
    $(#catalog).accordion();
    $(#catalog li).draggable({
        appendto: body,
        helper: clone,
        connecttosortable: #cart ol
    });
    $(#cart ol).sortable({
        items: li:not(.placeholder),
        connectwith: li,
        sort: function () {
            $(this).removeclass(ui-state-default);
        },
        over: function () {
            //hides the placeholder when the item is over the sortable
            $(.placeholder).hide();
        },
        out: function () {
            if ($(this).children(:not(.placeholder)).length == 0) {
                //shows the placeholder again if there are no items in the list
                $(.placeholder).show();
            }
        }
    });
});
另外值得一提的是
.ui-state-default貌似是拖拽时内置的一些类,对应的还有
ui-state-hover等分别对应当有可以拖拽的对象在拖拽时,和拖拽到容器时的效果,本文代码没有体现。
以上就是关于jqueryui中拖拽排序问题的分析了,希望大家能够喜欢。
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product