小编Hen*_*enk的帖子

jQuery live draggable/live droppable?

基本上有两个表:公司和访客.目前,可以将访客拖到公司.效果很好.一旦drop函数发生,就会有两个$ .post.第一个将拖动保存到数据库.第二个更新访问者,因为信息不断变化.但问题是,只要第二个$ .post结束,Firebug就会不断弹出以下错误:

d(this).data("draggable") is null
Run Code Online (Sandbox Code Playgroud)

这发生在jQuery UI文件中.在56号线上.

约400次左右.所以基本上我正在寻找一种方法来实现live()与draggable和droppable.

.draggables位于#visitors(ul)中.dropable是在#companies(一张桌子).

谢谢!

$(".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'
});
Run Code Online (Sandbox Code Playgroud)

ajax jquery jquery-ui live

6
推荐指数
2
解决办法
1万
查看次数

标签 统计

ajax ×1

jquery ×1

jquery-ui ×1

live ×1