Details
-
Bug
-
Status: Closed
-
Minor
-
Resolution: Fixed
-
1.4-M1
-
None
Description
There is a subtle problem, with the way how the autocomplete menu is created lazily in wicket-autocomplete.js when
the AbstractAutoCompleteBehaviour is used dynamically in Ajax roundtrips e.g. for adding addition auto complete
fields dynamically.
The auto complete menu is added as an addition <div> to the document and stays there even after an Ajax roundtrip, so
the <div> is reused, as well as mouse event listeners on the menu:
function getAutocompleteMenu() {
var choiceDiv=document.getElementById(getMenuId());
if (choiceDiv==null) {
var container = document.createElement("div");
....
container.onmouseout=function()
;
container.onmousemove=function()
};
However, since Wicket.AutoComplete get initialized a second time for during the Ajax update, a new mouseactive variable is created, which
is used in the closures for tweaking the even handling (onChange(), onBlur()), which never gets updated by these reused container (and hence
is always 0).
One simple solution to this problem is to cleanup the autocomplete menu in the initialize() if present:
function initialize(){
// Remove the autocompletion menu if still present from
// a previous call. This is required to properly register
// the mouse event handler again (using the new stateful 'mouseactive'
// variable which just gets created)
var choiceDiv=document.getElementById(this.getMenuId());
if (choiceDiv != null)
.....
}