views:

105

answers:

1

Hi, I have been trying hard to get this to work. I have a modal which I call when draggable - drag function is called. I want to drop the element into this modal which was called. I cannot seem to focus the draggable element into the modal. Can someone help me with this problem. Here is my code:

    $(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(

function(){

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

function(){

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

);

$(".tut-img").draggable( {
hoverClass: "dropHover", helper: "clone", opacity: "0.5", handle: ".tut-img", // makes toolbar the dragable part drag: function(ev, ui) { $('#newPerson').dialog("open"); }, stop: function(ev, ui) { $('#newPerson').dialog("close"); } } ); $(".newPersonDrop").droppable( { accept: ".tut-img", drop: function(ev, ui) { var droppedItem = ui.draggable.clone().addClass("droppedItemStyle");
$(this).append(droppedItem); alert('I get called');
} } );

});

A: 

First cache your dialog

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

In your droppable function

$('.newPersonDrop').droppable({
  //droppable options
  drop: function(event, ui){
    dialog.empty().append($(ui.draggable).clone());
  }
});
czarchaic
Hi, I tried what you suggested. It is acting quite strange. When i drag the image outside of the modal bounds all the way to the top and then come into the modal - i can drop it into the modal. Otherwise when i drag the image straight to the modal, it does not work! Any ideas as to why this might be happening?
paravamu