I'm encountering an issue with calling a javascript function when the value of a Dojo auto completer changes.
Despite trying to call the function through the "onChange" attribute, it doesn't work as expected.
Within the javascript function, my objective is to:
Invoke a struts2 action.
Update the value of a hidden field.
To trigger the action, I found another method:
publishing a topic using the attribute "valueNotifyTopic="topicName"", which allows me to perform the action by listening to the designated topic.
However, this approach doesn't fulfill the requirement of changing the hidden field's value. Hence, the necessity to execute a javascript function
Your guidance would be greatly appreciated
Thanks!!
Edit:
This snippet represents the code in the jsp file:
<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>
If I replace "valueNotifyTopics='viewContactInfo'" with "onChange='dojo.event.topic.publish('viewContactInfo');'", the action "viewContactInfo" fails to be triggered. Strangely, the "onChange" method works successfully for other elements in different parts of my project.