-2

我有一个带有打印按钮的拖放项目,一个按原样打印页面(在用户拖放任何内容之前),另一个我在加载时使用 JavaScript 禁用。在所有可拖动对象被删除后,如何激活第二个按钮?

$(document).ready(function() {
    $(".ui-widget-content").draggable({ revert: 'invalid', cursor: 'move', snapTolerance: '0px' }), 
    $("#dropcrown").droppable({ accept: '#crown'});
    $( "#dropneck" ).droppable({ accept: '#neck' });
    $( "#dropback" ).droppable({ accept: '#back' });
    $( "#droptail" ).droppable({ accept: '#tail' });
    $( "#dropwing" ).droppable({ accept: '#wing' });
    $( "#dropeye" ).droppable({ accept: '#eye' });
    $( "#dropbeak" ).droppable({ accept: '#beak' });
    $( "#dropcheek" ).droppable({ accept: '#cheek' });  
    $( "#dropbreast" ).droppable({ accept: '#breast' });
    $( "#dropbelly" ).droppable({ accept: '#belly' });
    $( "#dropfoot" ).droppable({ accept: '#foot' });
     $('#button2', this).attr('disabled', 'disabled');
     $('#button2', this).addClass( "ui-state-disabled" );
                });


            $(document).ready(function() {
        $( "#dropcrown, #dropneck ,#dropback, #droptail, #dropwing, #dropeye, #dropbeak, #dropcheek, #dropbreast, #dropbelly, #dropfoot" ).droppable({tolerance:'touch',
            drop: function( event, ui ) {
                $( this )
                    .addClass( "ui-state-highlight" );
                        var dropped = ui.draggable;
            var droppedOn = $(this);
            $(dropped).detach().css({top: 15,left: 7}).appendTo(droppedOn);
            $('#button', this).attr('disabled', 'disabled');
            $('#button', this).addClass( "ui-state-disabled" );

            }
        });
    });
    $(document).ready(function() {
        if($('#labels').html() == ""){
            $('#button2', this).removeAttr('disabled', 'disabled');
            $('#button2', this).removeClass( "ui-state-disabled" );
  //do something
}
    });
4

1 回答 1

0

jQuery UIDroppable有一个drop事件。将它挂在 droppables 上,当您看到事件时,请查看您要从中取出它们的容器。是空的吗?触发您想要触发的代码(例如,启用按钮)。

于 2012-04-14T16:00:47.360 回答