克隆对象不可放置 [英] Clone object is not droppable

查看:71
本文介绍了克隆对象不可放置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Jquery克隆可放置对象,但克隆的对象不可放置.

I'm trying to clone a droppable object using Jquery but the cloned object is not droppable.

$(document).ready(function(){
$("input[value='Add']").click(function(e){
e.preventDefault();
$("div.field:last").clone().insertAfter("div.field:last");
});

$(".field").droppable();

HTML

<div class="field">
Last Name<input type="text" value="" />
First Name<input type="text" value="" />
</div>
<div class="field">
Last Name<input type="text" value="" />
First Name<input type="text" value="" />
</div>
<input type="Submit" name="submit" value="Add" /> 

Firebug显示克隆的对象也具有ui-droppable类,知道为什么它不起作用吗?

Firebug shows that the cloned object has the class ui-droppable as well, any idea why it wouldn't work?

编辑
设置bool(true)或将克隆的对象与.droppable()链接都不起作用

EDIT
Setting bool(true) or chaining the cloned object with .droppable() is not working either

推荐答案

我找到了一种方法来实现此目标,方法是使用.live,我正在使用插件

I found out a way to accomplish this, by using the .live, I'm using a plugin .livequery which functions quite similiar with .live

绑定实时"事件时,它将绑定到页面上所有当前和将来的元素

When you bind a "live" event it will bind to all current and future elements on the page

$("input[value='Add']").livequery("click", function(e){
e.preventDefault();
$("div.field:last").clone().insertAfter("div.field:last");
$("div.field").droppable();

这篇关于克隆对象不可放置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆