拖放到对话框中

时间:2009-12-19 23:37:43

标签: jquery drag-and-drop modal-dialog

我正在努力使这项工作!我有一个div中的图像列表,我可以拖动。我还有一个在拖动开始时触发(打开)的对话框。出于某种原因,我无法进入此对话框。除了在对话框中,我可以放在页面上的其他地方。这是我的代码:

    $(document).ready(function(){
     // Executed once all the page elements are loaded
     //setup new person dialog   
    // Change overlay color and opacity
     $('#sample').dialog({
        //dialog options
        autoOpen: false,
                draggable: false,
                modal: false,
                show: 'explode',
                closeOnEscape: true,
                position: 'top',
                minHeight: '400',
                minWidth: '600',
                width: 750,
                title: "Some title",
                open: function(type, data) {
                    $(this).parent().appendTo("form");
                }
        });
 $(".random-img").draggable(
        {   
            cursor: "move",
            helper: "clone", 
            opacity: "0.5",
            zIndex: "2700",
            containment: "document",
            handle: ".random-img",    // makes toolbar the dragable part
            drag: function(ev, ui) {
               $('#sample').dialog("open");
            }
        }
     );
    $("#sample").droppable(
    {
        accept: ".random-img",
        tolerance: "touch",
        drop: function(ev, ui) 
        {                  
           var droppedItem = ui.draggable.clone().addClass('sclass');                  
                $(this).append(droppedItem);                             
        }     
    }
    );
   });

</script>
<html>
 <head> Page test </head>
   <body>
             <div class="random-img">
               <img src="images/someimage.jpg" />            
             </div>
              <div id='sample'>
              </div>
    </body>
 </html>

非常感谢任何帮助或见解。

由于

1 个答案:

答案 0 :(得分:1)

我终于明白了!经过数小时和数小时的尝试,这是有效的。我从draggable移动了对话框打开方法:拖动到draggable:start。然后我开始得到错误说这个draggable方法上的.helper是null或者不是firefox工具上的对象 - >错误控制台。

我鞭打了萤火虫,现在它完美无缺!

感谢您的帮助! 普利文