javascript - Which types of datas can I use in a Jquery autocomplete example in JSP -
<% usrealmmanager manager = new usrealmmanager(); list<usrealm> realmlist = manager.realmlist(); %> <select name="realms"> <%for (usrealm usrealm : realmlist) {%> <option value="<%=usrealm.getusrealmid()%>"><%=usrealm.getrealmname()%> </option> <%}%> </select>
i have list of objects in jsp , filling select tag them. need write autocomple jquery cant use realmlist on javascript side. should do? couldnt parse java object list json.
you can use autocomplete widget jquery ui (https://jqueryui.com/autocomplete/). plugin can create javascript array java pojos , pass autocomplete method.
using example on jquery ui sites:
<% usrealmmanager manager = new usrealmmanager(); list<usrealm> realmlist = manager.realmlist(); %> <script> $(function() { var availabletags = [ <%for (usrealm usrealm : realmlist) {%> { label: '<%=usrealm.getrealmname()%>', value: '<%=usrealm.getusrealmid()%>' } <%}%> ]; $( "#tags" ).autocomplete({ source: availabletags }); </script>
Comments
Post a Comment