【发布时间】:2012-05-11 10:31:56
【问题描述】:
我有一个拖放代码可以在服务器端创建的 div 上完美运行,但是当我使用 jquery(动态)创建一个 div 时,我似乎无法将任何东西放入容器中......
$('.dropcontent').droppable({
accept: '.item',
drop: function(ev, ui) {
/* do something */
}
});
$(".item").draggable({
helper:'clone',
appendTo: 'body',
snap: true,
revert: true
});
<div id="row1seo" class="dropcontent" > </div> // original code on server side
<div id="row1seo" class="dropcontent ui-droppable"> </div> // the above line becomes this on client side showing it has "binded" with the droppable
<div id="row2seo" class="dropcontent"></div> // this the dynamically created div which doesn't seem to bind with the droppable. this is created in php file using ajax to retrieve it
我也试过了
$(".dropcontent").live('droppable', function() {
......
});
似乎不起作用...任何想法如何解决这个问题?
谢谢
【问题讨论】:
-
动态创建的 div 是使用 ajax 从 php 文件中调用的...所以它不是使用 jquery/js 创建的
-
只是设置一个小提琴,jsfiddle.net
-
对于 js fiddle 来说太复杂了
标签: jquery jquery-ui drag-and-drop