jQuery:将一个控件的所有事件绑定到另一个控件
这可能是一个简单的问题,但我无法理解它。
我有 2 个 jQuery UI 滑块控件。 一个是作为我正在使用的插件的一部分生成的,但由于它位于布局中完全错误的位置,并且插件通过使用parent()等引用它,我只是将其设置为隐藏。
现在有我创建的第二个滑块控件,它应该具有与我隐藏的自动生成的控件完全相同的功能。
我如何告诉第二个控件它的行为应该与第一个控件一样?
可以这么说:
#control_1 = hide / 具有所有所需的功能,但在布局中定位错误
#control_2 = needs to inherit all events from #control_1
this might be a simple questions but I can't get my head around it.
I have 2 jQuery UI Slider Controls.
One is generated as part of the Plugin I am using but since it is positioned at a totally wrong place in the layout and the Plugin references it through the use of parent() etc I have simply set it to be hidden.
Now there is the second slider control which I have created and which is supposed to have the exact same functionality as the autogenerated control that I have hidden.
How can I tell the second control that it is supposed to behave just as the first control?
so to say:
#control_1 = hidden / has all the needed functionality but is positioned wrong in the layout
#control_2 = needs to inherit all events from #control_1
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以
克隆
原始控件:然后您可以将其附加到DOM在需要的地方。克隆绑定到元素的任何事件处理程序还需要
true
参数,因为默认情况下它们会被忽略。You could
clone
the original control:You could then append it to the DOM in the required place. The
true
arguments are needed to also clone any event handlers bound to the element, as they are ignored by default.