开发者

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

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 开发者_StackOverflow社区in my project).


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!!

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜