You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by "Igor Vaynberg (JIRA)" <ji...@apache.org> on 2009/05/04 19:22:30 UTC
[jira] Commented: (WICKET-2253) JavaScript null reference in IE7
for autocomplete text fields added by AJAX
[ https://issues.apache.org/jira/browse/WICKET-2253?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12705653#action_12705653 ]
Igor Vaynberg commented on WICKET-2253:
---------------------------------------
the init javascript ( new Wicket.AutoComplete(...) ) is rendered via response.renderOnDomReadyJavascript(initJS); (AbstractAutoCompleteBehavior:54) which means it should execute *after* the markup for the component has been placed into dom.
please create a quickstart that reproduces this error so we can see it in action.
> JavaScript null reference in IE7 for autocomplete text fields added by AJAX
> ---------------------------------------------------------------------------
>
> Key: WICKET-2253
> URL: https://issues.apache.org/jira/browse/WICKET-2253
> Project: Wicket
> Issue Type: Bug
> Reporter: Per Cederberg
> Fix For: 1.3.6, 1.4-RC2
>
>
> IE7 displays an null reference error when adding a Wicket AutoCompleteTextField to a form as part of an AJAX response. This is caused by the INPUT DOM element not being immediately accessible, since it is added as HTML text (via innerHTML) instead of via the normal DOM API:s. So, the JavaScript autocomplete initialization code must be delayed until the HTML code has been parsed and properly inserted into the DOM tree.
> We've solved this by patching our local copy of Wicket 1.3.x in the wicket-autocomplete.js file:
> @@ -39,6 +37,7 @@
> var KEY_CTRL=17;
> var KEY_ALT=18;
>
> + var initCounter=10; // counter to avoid eternal init calls
> var selected=-1; // index of the currently selected item
> var elementCount=0; // number of items on the auto complete list
> var visible=0; // is the list visible
> @@ -63,6 +62,24 @@
> var throttleDelay = 300;
>
> function initialize(){
> + // Ugly hack to avoid null reference in IE7...
> + if (initCounter <= 0) {
> + return;
> + }
> + initCounter--;
> + var obj=wicketGet(elementId);
> + if (obj == null) {
> + setTimeout(initialize, 100);
> + return;
> + }
> + initCounter=0;
> +
> + // Avoid initializing same element twice
> + if (obj.wicketInit) {
> + return;
> + }
> + obj.wicketInit=true;
> This is not an optimal solution, but with the current Wicket solution of injecting HTML code as text into the DOM tree one is forced to poll for the inserted DOM node...
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.