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:
Call a struts2 action.
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).