jQuery UI draggable problem

Discussion in 'jQuery' started by iliketrichs, May 15, 2013.

  1. #1
    I am creating a table that allows the user to **drag** cells into a new location.

    It works like this:

    I clone the element on mousedown, append it, make it draggable, and position it exactly over the original element (mouse is still down at this point).

    After that happens, I want the user to be able to start dragging the cloned item right away.

    Currently, the item can only be dragged once the user releases the mouse and mouses down on it again.

    How do I streamline the process? As soon as the element appears, the user should be able to start dragging if their mouse is already down.

    I have tried using .trigger within a hover function, mousedown function, etc. to simulate the mouseup and mousedown again, but that was no use.

    $('td').mousedown(function(){
    //$('.dragCopy').draggable('disabled': true);
    console.log($(this).offset());
    $(this).clone().appendTo('body')
    .css({'position':'absolute','z-index':'100','left': $(this).offset().left, 'top': $(this).offset().top})
    .draggable().addClass('dragCopy')
    $('body').on('mouseup', '.dragCopy', function(){
    $('.dragCopy').remove();
    });
    });
     
    iliketrichs, May 15, 2013 IP