问题
I want to use a autocomplete combobox http://jqueryui.com/demos/autocomplete/#combobox within a modal dialog. However whenever I click on the down arrow (of the combobox) it causes a refresh that results in my modal window closing.
How do I stop the refresh from occuring? (I am still new to jQuery)
I am using UI 1.8 and jQuery 1.4.1.
回答1:
The problem is discussed on the jQuery forum here: http://forum.jquery.com/topic/autocomplete-combobox-problem-when-it-is-placed-inside-a-form-tag
They suggest several different ways of adjusting the source code of the autocomplete combo to fix it. The simplest one seems to be this:
Change the line that says
$("<button> </button>")
to
$("<button type=\"button\"> </button>")
this prevents the type="submit"
from being inserted into the final button.
回答2:
Ok I fixed my own problem by removing the form tag from around the combobox
来源:https://stackoverflow.com/questions/2535240/jquery-ui-autocomplete-combobox-in-a-modal-dialog