Prolem with 'mouseactive' in wicket-autocomplete.js when AutoCompleteBehaviour
is added (twice) during Ajax roundtrip
---------------------------------------------------------------------------------------------------------------------
Key: WICKET-1659
URL: https://issues.apache.org/jira/browse/WICKET-1659
Project: Wicket
Issue Type: Bug
Components: wicket-extensions
Affects Versions: 1.4-M1
Reporter: Roland Huss
Priority: Minor
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() {
mouseactive=0;
};
container.onmousemove=function() {
mouseactive=1;
}
};
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) {
choiceDiv.parentNode.parentNode.removeChild(choiceDiv.parentNode);
}
.....
}
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.