Jquery 插件。组合框。更改事件
我对这个插件有问题 http://jquery.sanchezsalvador.com/jquery/page/ jquerycombobox.aspx 在我的页面上有几个选择框,由 jquery.combobox 转换。就其转换而言,它具有不同的 html,就像这样
<input class="combobox_hidden" type="hidden" name="prtnr" id="prtnr" value="Value">
我阅读了有关此插件中事件的文档。我想听 onChange 事件并做一些事情,但它不起作用。
var allsels;
var sels = $("select");
if (sels.length)allsels = sels.combobox();
........
allsels.combobox.onChange=function(){....};
这里有什么问题吗?
I have a problem with this plugin http://jquery.sanchezsalvador.com/jquery/page/jquerycombobox.aspx
On my page there are a few select boxes, which transformed by jquery.combobox. As far as it's transformed, it has different html like this
<input class="combobox_hidden" type="hidden" name="prtnr" id="prtnr" value="Value">
I read documentation about events in this plugin. I wanna listen to onChange event and do something, but it doesn't work.
var allsels;
var sels = $("select");
if (sels.length)allsels = sels.combobox();
........
allsels.combobox.onChange=function(){....};
What is wrong here?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在最后一行,
我个人觉得这个文档令人困惑:
那么 $('#id').combobox() 的返回结果是一个组合框对象...具有组合框属性?
On the last line, try
I find this documentation confusing, personally:
So the return result of $('#id').combobox() is a combobox object... with a combobox attribute?
您始终可以将 onchange 处理程序附加到原始元素。
请参阅实例中的页面源(特别是第 116 行选择的“动画类型”): jquery.sanchezsalvador.com/samples/example.htm
我设计了 jquery.combobox,以便在使用时现有代码不会中断,并且您的事件处理程序会受到尊重。
@Anton:这是我的第一个 jquery 小部件。我也不喜欢我对 $(selector).combobox 所做的事情,它既是函数又是状态对象。
You can always just attach an onchange handler to the original element.
see the source of the page (specifically the "animation types" select on line 116) in the live example: jquery.sanchezsalvador.com/samples/example.htm
I designed jquery.combobox so that when used, existing code would not break and your event handlers are respected.
@Anton: this was my first jquery widget. I also don't like what I've done with $(selector).combobox, where it is both a function and a state object.