jQueryUI droppable, stop propagation to overlapped sibling

前端 未结 9 924
忘了有多久
忘了有多久 2020-12-02 01:59

As you can see here: http://jsfiddle.net/rA4CB/6/

When I make the drop in the overlapped area it is received in both droppables, greedy doesn\'t work when the items

9条回答
  •  被撕碎了的回忆
    2020-12-02 02:22

    Okay, so I spend an hour trying to figure it out, then as soon as I ask I then find my answer

    http://jsfiddle.net/rA4CB/7/

    Modified the JS to the following:

    $(function() {
        $( "#draggable" ).draggable();
        $( "#droppable" ).droppable({
            tolerance:'pointer',
            drop: function( event, ui ) {
                $( this )
                    .addClass( "ui-state-highlight" )
                    .find( "p" )
                        .html( "Dropped!" );
            }
        });
        $( "#droppable2" ).droppable({
            tolerance:'pointer',
            greedy:true,
            drop: function( event, ui ) {
                $( this )
                    .addClass( "ui-state-highlight" )
                    .find( "p" )
                        .html( "Dropped!" );
            },
            over: function(event, ui){
                $( "#droppable" ).droppable( "disable" )
            },
            out: function(event, ui){
                $( "#droppable" ).droppable( "enable" )
            }
        });
    });
    

提交回复
热议问题