jQuery live draggable / live droppable?

Posted by Henk on Stack Overflow See other posts from Stack Overflow or by Henk
Published on 2010-06-10T17:26:28Z Indexed on 2010/06/11 11:32 UTC
Read the original article Hit count: 1747

Filed under:
|
|
|

Hi all,

Basically there are two tables: Companies and visitors. Currently it's possible to drag visitors to companies. Works great. As soon as the drop function occurs, there are two $.post's. The first one saves the drag to the database. The second one updates the visitors, because the information constantly changes. The problem, however is that as soon as the second $.post finishes, Firebug keeps popping the following error:

d(this).data("draggable") is null

Which occurs in the jQuery UI file. On line 56.

about 400 times or so. So basically I'm looking for a way to do live() with draggable and droppable.

The .draggables are in #visitors (an ul). The droppables are in #companies (a table).

Thanks!

$(".draggable").draggable({
    revert:true
});
$(".droppable").droppable({
    drop: function(ev, ui) {
        $(this).text($(ui.draggable).text());

        $.post('planning/save_visit', {user_id: $(ui.draggable).attr('id'), company_id: $(this).attr('id'), period: $('ul.periods li.active').attr('id')});

        $.post('planning/' + $('ul.periods li.active').attr('id'), {visitors:true}, function(data){
            $('#visitors').html(data);
        });
    },
    hoverClass: 'drophover'
});

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about AJAX