Close autocomplete when the dialog is closed:
$("#dialog").dialog({ close: function() { $('#tags').autocomplete('close'); } });
See this in action: http://jsfiddle.net/william/3Yz9f/1/ .
Update
It depends on what you mean by being "general." JavaScript is very event driven. So, initially you want autocomplete to close when the dialog is closed, therefore, the first part of the answer. Of course, you can bind it to some indirect events, such as auto-fill blur or hide (you may need to make a special event to hide), but this gives you a little risk that they may not be triggered, since they are indirect.
Now you want it to close when you drag the dialog; well, itβs also not difficult; you can achieve this with the dragStart event for a dialog, but these are two different events, both in dialogs and not in autocomplete. I do not see any indirect event in the autocomplete widget itself when dragging a dialog.
If your problem relates to an autocomplete widget by id, you can use a context-based selector, for example. use $('.ui-autocomplete-input', this) instead of $('#tags') in dialog event handlers.
source share