简体   繁体   English

struts2 jQuery自动完成

[英]struts2 jquery autocomplete

I have followed the sample of Struts jQuery Autocompleter and the tag with attributes 我遵循了Struts jQuery Autocompleter和带有属性的标签的示例

<sj:autocompleter id="destination" name="destination" list="%{locationList}" listValue="name"  listKey="id" selectBox="true" selectBoxIcon="true" 
cssClass="styled-dropdown" onSelectTopics="autocompleteSelect"/>

and have 并有

$.subscribe('autocompleteSelect', function(event,data).

My question is after a location is selected, I would like to get the selection key value then query geocode from db then reload the map marker on the map. 我的问题是选择位置后,我想获取选择键值,然后从db查询地理编码,然后在地图上重新加载地图标记。 I tried to use getElementById on the input tag "destination" which autocompleter generates for me but the value doesn't set yet during the autocompleteSelect event. 我尝试在自动完成程序为我生成的输入标签“目标”上使用getElementById,但在autocompleteSelect事件期间尚未设置该值。 Is there a way that I can get the "input" tag value during the autocomplete selection? 有没有一种方法可以在自动完成选择期间获取“输入”标签值?

And I could get the key value using (event.originalEvent.ui.item.option['value']) in the subscribe event, but I don't know how to replace the old map marker with the new one for I have 2 autocomplete tags, one is for startLocation and one is destination. 而且我可以在订阅事件中使用(event.originalEvent.ui.item.option ['value'])来获取键值,但是我不知道如何用新的替换旧的地图标记,因为我有2自动完成标记,一个用于startLocation,一个用于目标。 Is there any way to let event know which element is calling autocompleteSelect? 有什么办法让事件知道哪个元素正在调用autocompleteSelect?

Thanks 谢谢

You have to bind the href of the widget of your second autocompleter to the old json query + an extraparmeter using 您必须将第二个自动完成器的小部件的href绑定到旧的json查询+一个额外的参数,使用

jQuery.struts2_jquery_ui.bind(widget,options_auto_iban_widget);

I just post an example on : How to reload the struts2-jquery autocompleter X with value selected from another struts2-jquery autocompleter Y 我只是在以下示例上发布: 如何使用从另一个struts2-jquery自动完成程序Y中选择的值重新加载struts2-jquery自动完成程序X

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM