试图使动态创建的元素可拖动 [英] Trying to make dynamically created element draggable

查看:68
本文介绍了试图使动态创建的元素可拖动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建可拖动的动态输入元素。现在的问题是我创建了一个元素,但是当我使用类似

I'm trying to create a dynamic input element that is draggable. Now the problem is I create an element but when I use something like

$("#in"+index.toString()).draggable({cancel:true});

在将其附加到容器div后,它不起作用。基本上,它不适用于特定ID的动态创建的input元素。这是代码,请随时指出问题。我真的可以为此提供一些帮助。谢谢!

after I append it to the container div, it's not working. Basically it's not working for the dynamically created input element of a certain id. Here's the code and please feel free to point out problems. I could really use some help on this one. Thanks!

http://jsfiddle.net / ithril / hRCun / 5 /

推荐答案

问题是您正在创建未绑定的新元素UI功能。我建议使用 clone(true,true),然后根据需要更改克隆元素的参数。您可以在此处了解有关克隆的更多信息。 http://api.jquery.com/clone/

The problem is that you are creating a new element that is not bound to the UI functions. I would suggest using clone(true,true) and then changing the parameters of the cloned element as need be. You can learn more about clone here. http://api.jquery.com/clone/

这篇关于试图使动态创建的元素可拖动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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