当Dojo自动完成器的值更改时调用java脚本函数 [英] Calling a java-script function when value of a Dojo auto-completer changes
问题描述
从onChange属性调用javascript函数没有任何作用(<我的意思是函数不被调用/执行)
在javascript函数中,我想:
-
调用struts2动作
-
更改隐藏字段的值。
对于调用动作我有另一种方式:
使用属性valueNotifyTopic =topicName发布主题,然后我可以调用通过听取主题的一个动作。
但是我不能通过这种方式改变隐藏字段的值。所以我需要调用一个javascript函数
请指教
谢谢!!
编辑:
这是jsp中的代码:
< s:url id =scriptURLaction =viewContactInfo/>
< sd:div href =%{scriptURL}listenTopics =viewContactInfoformId =contactInfoshowLoadingText =falsepreload =false>
< s:form id =contactInfo>
< sd:autocompleter autoComplete =falsename =customerlist =customerListvalueNotifyTopics =viewContactInfo/>
< sd:autocompleter autoComplete =falsename =contactlist =contactListvalueNotifyTopics =viewContactInfo/>
< s:hidden id =chngdvalue =initial/>
< / s:form>
< / sd:div>
如果我将valueNotifyTopics ='viewContactInfo'更改为onChange ='dojo.event.topic .publish('viewContactInfo');'actionviewContactInfo停止调用。而同样的事情(onChange)与其他元素(在我的项目的其他地方)一起使用。
我已经开始了这个问题的另一个线索。
我想出了解决方案,并在此发布了答案:
希望这有帮助!!
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).
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!!
这篇关于当Dojo自动完成器的值更改时调用java脚本函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!