Calling a java-script function when value of a Dojo auto-completer changes

只谈情不闲聊 提交于 2019-12-11 06:24:39

问题


I am trying to call a javascript function when the value of a Dojo auto completer changes.

Calling the javascript function from the "onChange" attribute has no effect (I mean the function is not called/executed).

In the javascript function I want to:

  1. Call a struts2 action.

  2. Change the value of a hidden field.

For calling the action I have another way :
publishing a topic using attribute " valueNotifyTopic="topicName" ", then I can call an action by listening to the topic.

But I cant change the value of the hidden field through this way. So I need to call a javascript function

Please advise

Thanks!!

Edit:

This is the code in the jsp:

<s:url id="scriptURL" action="viewContactInfo" />
<sd:div href="%{scriptURL}" listenTopics="viewContactInfo" formId="contactInfo" showLoadingText="false" preload="false">
<s:form id="contactInfo">
    <sd:autocompleter autoComplete="false" name="customer" list="customerList" valueNotifyTopics="viewContactInfo"/> 
    <sd:autocompleter autoComplete="false" name="contact"  list="contactList"  valueNotifyTopics="viewContactInfo"/>
    <s:hidden id="chngd" value="initial"/>
</s:form>
</sd:div>

Here if I change "valueNotifyTopics='viewContactInfo'" to "onChange='dojo.event.topic.publish('viewContactInfo');'" the action "viewContactInfo" stops getting called. Whereas the same thing (the "onChange" one) works with other elements (in other places in my project).


回答1:


I had started another thread for this question.

I figured out the solution and have posted the answer here :

Cannot find a way to pass a hidden value to the action file

Hope this helps!!



来源:https://stackoverflow.com/questions/7565149/calling-a-java-script-function-when-value-of-a-dojo-auto-completer-changes

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!