我正在使用jQuery 1.4.2 (j是.noConflict())/jQuery UI 1.8.5,我遇到以下代码的问题。jQuery 1.4.2/jQuery UI droppable - remove();问题与Internet Explorer或错误?
这在Chrome,FireFox和Safari中运行良好,但在Internet Explorer中无效。 alert();但是下面的行(remove();)没有。
XHTML标记:
<div class="mainarea">
<div class="dnd">
<div class="person dad"></div>
<div class="person mum"></div>
</div>
</div>
<div class="tools">
<div class="person dad"></div>
<div class="person mum"></div>
<div class="person boy"></div>
<div class="person girl"></div>
<div class="bin"></div>
</div>
Javascript代码:
j(document).ready(function(){
// make the source item draggable
j('.tools .person').draggable({
revert: "invalid",
helper: "clone"
});
// the target drag n'drop area
j('.dnd').droppable({
accept: ".tools > .person",
revert: "invalid",
activeClass: "active",
drop: function(event, ui) {
//copy from source and make it replaceable by another one
var obj = ui.draggable.clone().droppable({ hoverClass: "active", accept: ".tools .person" });
// in case of replace
if(j(".dnd > .person.active").size())
j(".dnd > .person.active").replaceWith(obj);
else // in case of new or limit reached
if((j(".dnd > .person.active").size() == 0) && (j(".dnd > .person").size() < 4))
obj.appendTo('.dnd');
}
});
// the bin to delete the selected persons
j('.bin').droppable({
accept: ".dnd > .person",
hoverClass: "active",
drop: function(event, ui) {
alert('debug');
ui.draggable.remove();
}
});
// makes drag n'drop is sortable
j(".dnd").sortable({ placeholder: 'empty' });
//helpers
j(".dnd").disableSelection();
});
有人可以帮助我吗? 谢谢。
我认为它也不起作用,当你删除'alert'?例如,你添加了调试?另外请注意,[Droppable的文档](http://jqueryui.com/demos/droppable/)表示'ui.draggable'已经是一个jQuery实例,你不需要调用'j'它再次(虽然它应该是无害的,如果你这样做)。 – 2010-10-13 11:12:46
您在标题中说过1.4.3,但在帖子正文中说过1.4.2。你在使用1.4.3 RC吗?还是公布的1.4.2? – 2010-10-13 11:33:28
该警报仅用于调试目的而已添加,并且可以正常工作。我在调用ui.draggable之前删除了_j_,但仍然无效。我刚刚编辑了我的标题:版本是1.4.2。 – 2010-10-13 13:02:12