jquery-ui-droppable无法区分两种可拖动的div?

发布于 2025-01-07 12:25:50 字数 249 浏览 3 评论 0原文

我在 Jqueryui Droppable 中有一个问题。抱歉,我的英语很差。 饱和度为: 现在,我有3个div,div a,div b和div c我使div a和div b可拖动,div c可放置。DIV C可以接受div a和div c。 问题是,现在 div c 可以接受 div a 和 div b 作为 Copy,或者 div c 可以接受 div a 和 div b 作为剪切。我希望 div c 可以接受 div a 作为复制,div b 作为剪切。我怎样才能明白了吗?

I have a question in Jqueryui Droppable.Sorry, my English is poor.
The satuation is:
now,I have 3 divs,div a,div b and div c.I make div a and div b to be draggable,div c to be droppable.DIV C can accept div a and div c.
The question is,now div c can accpet div a and div b as Copy,or div c can accpet div a and div b as Shear.I hope that div c can accept div a as copy and div b as Shear.How can i get this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

怼怹恏 2025-01-14 12:25:50

它(英语)是一个常见问题;)

您可以为可拖动对象设置类,然后在放置事件中匹配上下文。

$(function() {
    $( "#diva" ).draggable(
        drag: function(event, $ui) {
            $ui.addClass('copy');
        },
        stop: function(event, $ui) {
            $ui.removeClass('copy');
        }

    );
        $( "#divb" ).draggable(
        drag: function(event, $ui) {
            $ui.addClass('shear');
        },
        stop: function(event, $ui) {
            $ui.removeClass('shear');
        }

    );

    $( "#divc" ).droppable({
        drop: function( event, $ui ) {
            // you can access the dragglable html by this
            // and then can append it to anywhere, its like making its copy
                var html = $ui.draggable.html();
                if ($ui.draggable.hasClass('shear')) {
                    // destroy #divb here so that it looks like shear
                }
        }
    });
});

Its (English) a common problem ;)

You can set class for draggable objects and then later match context at drop event.

$(function() {
    $( "#diva" ).draggable(
        drag: function(event, $ui) {
            $ui.addClass('copy');
        },
        stop: function(event, $ui) {
            $ui.removeClass('copy');
        }

    );
        $( "#divb" ).draggable(
        drag: function(event, $ui) {
            $ui.addClass('shear');
        },
        stop: function(event, $ui) {
            $ui.removeClass('shear');
        }

    );

    $( "#divc" ).droppable({
        drop: function( event, $ui ) {
            // you can access the dragglable html by this
            // and then can append it to anywhere, its like making its copy
                var html = $ui.draggable.html();
                if ($ui.draggable.hasClass('shear')) {
                    // destroy #divb here so that it looks like shear
                }
        }
    });
});
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文