dojo:如何克隆小部件?
如何克隆 Dojo 表单 (dijit.form.Form) 及其子部件?理想情况下,我也想更改克隆小部件的 ID。我也有兴趣克隆可能附加到小部件的任何事件。
我玩了一下 dojo.clone 但这只适用于 DOM 对象。
谢谢
How do I go about cloning a Dojo form (dijit.form.Form) with its child widgets? Ideally, i'd like to change the Id's of the clone widgets as well. I also would be interested in cloning any events that might be attached to the widgets.
I played a bit with dojo.clone but that only works for DOM objects.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
假设继承确实是您所需要的,那么我只需制作一个新的小部件。假设您正在使用异步加载器和 Dojo 1.7。我会做类似的事情:
如果您使用同步加载器,那么您将需要
dojo.declare
:然后您的模块将可通过
var container = someElement; 来使用。新的path.to.File({},容器);
。或者您可以在标记中声明该小部件。请告诉我是否可以使其更具体或适用于不同版本的 Dojo。Assuming inheritance is really what you need, then I'd just make a new widget. Assuming you are using the async loader and Dojo 1.7. I'd do something like:
If you're using the sync loader, then you'll want
dojo.declare
:Your module will then be available with
var container = someElement; new path.to.File({}, container);
. Or you could declare the widget in your markup. Let me know if I can make this more specific or apply to different versions of Dojo.