开发者

YUI Custom Event for Dropdown value pre-selection?

I have a dropdown field and its value is pre-selected as soon as its rendered (Say, its a Country field in a signup form). And I have other dropdowns or other components which change the selected value of the first dropdown dynamica开发者_C百科lly. Now I want to fire a method with every "value getting selected" in the dropdown. Is it possible?

To put my question in much more clearer way, I want to create a onDefaultValueSet event and subscribe the first dropdown to it. So in which ever way the dropdown gets any value selected, the corresponding handler (my function) gets called.

I tried to do it with YUI Custom Events, but I am not sure how the browser will be calling(understanding) my handler every time a value is selected in the dropdown.

onSelect (from Default DOM) is not a right answer I guess, as I tried it.

Please help me in tackling this problem.


I am not sure whether this is an answer, but I've found a workaround. Please validate this.

So I was making a item "selected" using javascript-dom manipulation. Meaning, using

domElement.options[5].selected = True;

So with the (YUI)custom event I created, I started calling "fire()" right after this. So the code becomes:

domElement.options[5].selected = True;
onDefaultValueSetEvent.fire(domElement.name);

But I am not sure, what if the particular option is selected in a gui fashion. Meaning, how automatically fire() method is called

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜