0

我一直在努力让它发挥作用。我有一个模态,我在可拖动时调用 - 调用拖动函数。我想将元素放入这个被调用的模式中。我似乎无法将可拖动元素集中到模态中。有人可以帮我解决这个问题。这是我的代码:

    $(document).ready(function(){
    // Executed once all the page elements are loaded
     //setup new person dialog
        $('#newPerson').dialog({
                autoOpen: false,
                draggable: false,
                modal: true,
                closeOnEscape: true,
                height: '400px',
                width: '600px',
                title: "Drag to FB, Twitter",
                open: function(type, data) {
                    $(this).parent().appendTo("form");
                }
            });  

 // The hover method takes a mouseover and a mouseout function:
 $(".tut").hover(

功能(){

$(this).find('.drag-label').stop().animate({marginTop:'-50px'},'fast'); },

功能(){

$(this).find('.drag-label').stop().animate({marginTop:'0'},'fast'); }

);

$(".tut-img").draggable( {
hoverClass: "dropHover", helper: "clone", opacity: "0.5", handle: ".tut-img", // 使工具栏成为可拖动部分 drag: function (ev, ui) { $('#newPerson').dialog("open"); }, 停止: function(ev, ui) { $('#newPerson').dialog("close"); } } ) ; $(".newPersonDrop").droppable( { accept: ".tut-img", drop: function(ev, ui) { var droppedItem = ui.draggable.clone().addClass("droppedItemStyle");
$(this )。附加(丢弃的项目);alert('我被叫');
} } );

});

4

1 回答 1

0

首先缓存你的对话框

var dialog=$('#newPerson').dialog({
  //dialog options
});

在您的可放置功能中

$('.newPersonDrop').droppable({
  //droppable options
  drop: function(event, ui){
    dialog.empty().append($(ui.draggable).clone());
  }
});
于 2009-12-14T02:15:18.337 回答