简体   繁体   中英

struts2 jquery autocomplete

I have followed the sample of Struts jQuery Autocompleter and the tag with attributes

<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. 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. 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. Is there any way to let event know which element is calling autocompleteSelect?

Thanks

You have to bind the href of the widget of your second autocompleter to the old json query + an extraparmeter using

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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