繁体   English   中英

jQuery Droppable克隆,但不删除

[英]Jquery Droppable clone, but do not remove

我正在使用jquery的拖放照片管理器,并且需要一些稍微改变的功能。 您可以查看例如。 在下面的链接中。

http://jqueryui.com/droppable/#photo-manager

我想要做的是,当您将图像拖到拖放区中时,我想向其添加一个类,而不是从原始列表中消失。

我不知道该在哪里做?

$trash.droppable({
  accept: "#gallery > li",
  activeClass: "ui-state-highlight",
  drop: function( event, ui ) {
        ui.draggable.addClass('my-new-thing');
        var $list = $( "ul", $trash ).length ? $( "ul", $trash ) : $( "<ul class='gallery ui-helper-reset'/>" ).appendTo( $trash );
        ui.draggable.clone().append( recycle_icon ).appendTo( $list ).fadeIn();
  }
});

我想你要这个

    // let the trash be droppable, accepting the gallery items
    $trash.droppable({
        accept: "#gallery > li",
        activeClass: "ui-state-highlight",
        drop: function( event, ui ) {
            deleteImage( ui.draggable );
            ui.draggable.addClass('new1');
        }
    })

当元素位于放置区中时,可以使用drop事件来捕获事件。

$( ".selector" ).droppable({
    drop: function( event, ui ) {
        // Add your class here
    }
});

有关http://api.jqueryui.com/droppable/#event-drop的更多信息

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM