return FALSE; $r = well_tag_thread__update(array('id' => $id), $update); return $r; } function well_tag_thread_find($tagid, $page, $pagesize) { $arr = well_tag_thread__find(array('tagid' => $tagid), array('id' => -1), $page, $pagesize); return $arr; } function well_tag_thread_find_by_tid($tid, $page, $pagesize) { $arr = well_tag_thread__find(array('tid' => $tid), array(), $page, $pagesize); return $arr; } ?>javascript - Jquery UI Draggable clone disappearing - Stack Overflow
最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Jquery UI Draggable clone disappearing - Stack Overflow

programmeradmin1浏览0评论

I am trying to use the jquery-ui draggable to make some element draggable. I set the helper option to clone the current element.
It's making the clone correctly but when I drop the clone disappears. It doesn't stay at the dragged place.

See this for Demo Fiddle Link

$('#drag').draggable({
helper: function (e, ui) {
    return $(this).clone();
}
});

What am I missing ?

I am trying to use the jquery-ui draggable to make some element draggable. I set the helper option to clone the current element.
It's making the clone correctly but when I drop the clone disappears. It doesn't stay at the dragged place.

See this for Demo Fiddle Link

$('#drag').draggable({
helper: function (e, ui) {
    return $(this).clone();
}
});

What am I missing ?

Share Improve this question edited Aug 30, 2015 at 15:47 tezkerek 1863 silver badges6 bronze badges asked May 24, 2015 at 10:10 SaifSaif 7,0528 gold badges42 silver badges62 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 7

There maybe a simpler way, but through data of draggable, you can target a property that deals with this. Like this:

stop : function(e, ui){
         $('#drag').draggable().data()["ui-draggable"].cancelHelperRemoval = true;
    }

fiddle: http://jsfiddle/n10ucrLd/

I think there's been a lot of troubles with helper: 'clone'. I always got it to work, when I defined a droppable as well. E.g.:

HTML:

<div id="drag">Drag This</div>
<div class="container"></div>

JavScript:

$('#drag').draggable({
helper: function (e, ui) {
    return $(this).clone(true);
}
});

 $( ".container" ).droppable({
    drop: function (event, ui) {
       ui.draggable.clone().appendTo($(this)).draggable();
    }
 });

Live example: http://jsbin./vibeqaganu/1/edit?html,css,js,output

发布评论

评论列表(0)

  1. 暂无评论