Grails-UI AutoComplete - How to specify default value

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Grails-UI AutoComplete - How to specify default value

mordekai
Hello,

I have an autocomplete field for entering the location in my app and it works fine.
Now, I would like to remember the location the user entered and default to that the next time the user visits the page.

However, when I specify the 'value' attribute the input field will default to the correct value, but once the form is submitted the locationAutoComplete_id parameter is empty.

This is the code in the gsp:

<gui:autoComplete
                        id="locationAutoComplete"
                        controller="location"
                        action="locationAutoComplete"
                        forceSelection="true"
                        minQueryLength='1'
                        value='${session.location}'
                        queryDelay='0.5'/> 


I am thinking I might need to trigger the autocomplete to initialize somehow, or even fake it by setting the value of the hidden field using javascript.

Thoughts?

Thanks a lot.

/Maarten
Reply | Threaded
Open this post in threaded view
|

Re: Grails-UI AutoComplete - How to specify default value

SADman_H
try use:

--------------------------------------------------------------
<div onClick="addValue();" onKeypress="addValue();">
   <gui:autoComplete
                        id="locationAutoComplete"
                        controller="location"
                        action="locationAutoComplete"
                        forceSelection="true"
                        minQueryLength='1'
                        value='${session.location}'
                        queryDelay='0.5'

   />
</div>
<g:hiddenField name="value_id"  value="${session.id}" />

------------------------------------------------------------
<script language='Javascript'> function addValue() { document.getElementById('value_id').value=document.getElementById('locationAutoComplete_id').value; } </script>-------------------------------------------------------------

now. use value_id parameter