开发者

Jquery plugin. Combobox. Event onChange

开发者 https://www.devze.com 2023-03-10 03:29 出处:网络
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

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?


On the last line, try

allsels.onChange = function () {...};

I find this documentation confusing, personally:

usage:

var elementJQ = $("#id").combobox(); elementJQ.combobox.onChange = function(){};

or $("#id").combobox().onChange = function(){};

So the return result of $('#id').combobox() is a combobox object... with a combobox attribute?


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消