2 Replies Latest reply: Aug 4, 2014 5:54 AM by Tom Petrus RSS

    Event autochangeselect in Apex?


      Hi guys,


      I tried to find an answer here - Text item with autocomplete and empty return values in js - but no success.


      My problem: I have a text field with autocomplete (enterprise names).

      When the user clicks on a name or hits enter, the item should be set into session state and a dynamic action should be executed (PL/SQL code that populates the whole form).


      Problem: The onchange event in Apex only works when the user hits enter and tabs to another field. (would be great if it submits the item already after hitting enter)

      When the user uses the mouse however, only the query value is submitted (e.g. "Ora" when I want to search for Oracle).


      I checked the jquery autocomplete documentation, the event is "autocompleteselect" or "...change", don't really know.


      How can I incorporate this in Apex?




        • 1. Re: Event autochangeselect in Apex?



          Can you please put your apex info version,db ...


          Also if you can create an example on apex.oracle.com that would be great..




          • 2. Re: Event autochangeselect in Apex?
            Tom Petrus

            First thing to note is that the apex item type "Text field with autocomplete" is NOT based on jQueryUI Autocomplete (up to and including 4.2.5).

            * @fileOverview
            * The {@link apex.widget}.autocomplete is used for a textfield widget which shows a list of values based on the entered text.
            * Internally the jQuery autocomplete plug-in http://plugins.jquery.com/project/autocompletex
            * is used. See the plug-in docu for available options.

            So you should disregard the JQUI docs if you wish to use this itemtype.

            The plugin code used doesn't fire the change event at all, and binding to the change event will simply confuse you. When trying this on apex.oracle.com I do get a change event when selecting with the mouse but not by using tab or enter. Even so, the change event happens for the reasons described in the linked thread: because the focus on the input item is lost for a bit, the change event fires on the element. But the value will not be set correctly at that point. The focus is moved back programmatically.

            The plugin code does fire the "result" event, and this is what you should be binding to. Just select "Custom event" for the DA and enter "result" (without quotes) for name.

            That should pretty much work for any apex version, though the setup may very since I don't think the "custom event" selection is there in previous versions (can't remember). Set up an example on apex.oracle.com if you can't figure it out and share the workspace name + developer credentials here.