Wicket
  1. Wicket
  2. WICKET-4990

Problem using AutoCompleteBehavior with AjaxFormComponentUpdatingBehavior("onchange")

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 6.4.0
    • Fix Version/s: 6.6.0
    • Component/s: wicket
    • Labels:
      None

      Description

      Given a text field that uses the following behaviors:
      A. AjaxFormComponentUpdatingBehavior("onchange");
      B. AutoCompleteBehavior

      Say I enter an letter 'U' into the text field, and an auto-suggest list pops up.
      When I select an item (e.g. USD) from the auto-suggest list using a mouse, the onchange event from behavior A is fired twice. The 1st onchange event is for 'U' and the 2nd onchange event is for 'USD'.

      This issue is mentioned as a regression by Sven Meier and related to WICKET-1280.

        Issue Links

          Activity

          Hide
          james yong added a comment -

          Here is how I fix it:
          Add the following to auto-complete.js / auto-complete.min.js,

          var onchangehandlers;
          ....
          function showAutoComplete(){var input=Wicket.$(elementId);
          if(onchangehandlers==null || onchangehandlers.length==0){
          var c = (jQuery.hasData(input)&&jQuery._data(input)).events['change'];
          if (c!=null&&c.length>0){
          onchangehandlers=[];
          jQuery.each(c, function(index, value)

          { onchangehandlers[index]=value.handler; }

          );
          jQuery(input).off('change');
          }
          }
          ....
          function hideAutoComplete(){
          if(onchangehandlers!=null){
          jQuery.each(onchangehandlers, function(index, value)

          { jQuery(Wicket.$(elementId)).on('change', onchangehandlers[index]); }

          );
          onchangehandlers = null;
          }
          ......

          Show
          james yong added a comment - Here is how I fix it: Add the following to auto-complete.js / auto-complete.min.js, var onchangehandlers; .... function showAutoComplete(){var input=Wicket.$(elementId); if(onchangehandlers==null || onchangehandlers.length==0){ var c = (jQuery.hasData(input)&&jQuery._data(input)).events ['change'] ; if (c!=null&&c.length>0){ onchangehandlers=[]; jQuery.each(c, function(index, value) { onchangehandlers[index]=value.handler; } ); jQuery(input).off('change'); } } .... function hideAutoComplete(){ if(onchangehandlers!=null){ jQuery.each(onchangehandlers, function(index, value) { jQuery(Wicket.$(elementId)).on('change', onchangehandlers[index]); } ); onchangehandlers = null; } ......
          Hide
          Sven Meier added a comment -

          Please test thoroughly, I had to change a few things to adapt for the new non-inline event handlers.

          Show
          Sven Meier added a comment - Please test thoroughly, I had to change a few things to adapt for the new non-inline event handlers.
          Hide
          james yong added a comment -

          Hi Sven,

          I have found some regressions caused by my code changes. Still testing some additional code changes.

          Regards,
          James

          Show
          james yong added a comment - Hi Sven, I have found some regressions caused by my code changes. Still testing some additional code changes. Regards, James
          Hide
          Sven Meier added a comment -

          Next release will be built soon, so hurry up with your testing.

          Show
          Sven Meier added a comment - Next release will be built soon, so hurry up with your testing.
          Hide
          james yong added a comment -

          Hi Sven,

          I need much more time to fix the regression. Please revert the change. Sorry about that.

          Regards,
          James

          Show
          james yong added a comment - Hi Sven, I need much more time to fix the regression. Please revert the change. Sorry about that. Regards, James
          Hide
          Sven Meier added a comment -

          Please open a new issue when you're ready. Autocomplete works fine here with the recent changes together with AjaxFormComponentUpdatingBehavior.

          Show
          Sven Meier added a comment - Please open a new issue when you're ready. Autocomplete works fine here with the recent changes together with AjaxFormComponentUpdatingBehavior.

            People

            • Assignee:
              Sven Meier
              Reporter:
              james yong
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development