Wj-auto-complete selectedIndexChanged event fires on load

Posted by: guest on 14 September 2017, 2:18 am EST

    • Post Options:
    • Link

    Posted 14 September 2017, 2:18 am EST

    Hello,

    I need quick help, the selectedIndexChanged event fires on page load as demonstrated in fiddle. I need this event firing only on the changing the selection.

    How to avoid the event being fired on the page load?

    http://fiddle.jshell.net/orfrfvxv/

    Kind regards

  • Posted 14 September 2017, 2:18 am EST

    It appears that in the first fiddle example, on first controller load the event fires twice. I managed to make it fires once by adding flag, but this is still not acceptable.

    http://fiddle.jshell.net/orfrfvxv/2/

    I need solution where the event is not fired on controller load.

    Regards

  • Posted 14 September 2017, 2:18 am EST

    Hello Guest,

    It happens because by default, the first item is selected in AutoComplete. So, the selectedIndexChanged event fires twice i.e. one for setting selectedIndex as 0 and second for setting selectedIndex as -1.

    However, you can check whether the event is raised by user selection or not by setting the flag in the isDroppedDownChanged event. Here is the updated fiddle: http://fiddle.jshell.net/orfrfvxv/4/

    Regards

  • Posted 14 September 2017, 2:18 am EST

    Hello,

    Solution working excellent, thanks!

    Regards

  • Posted 16 August 2022, 10:41 pm EST

    hi I am facing same issue. Unable to access link

  • Posted 17 August 2022, 6:10 pm EST

    Hello,

    The link has changed because of the domain change of jsfiddle, the updated link for the above sample is given below:

    http://jsfiddle.net/orfrfvxv/4/

    You can also refer to the sample link below demonstrating the same in angular 11:

    https://stackblitz.com/edit/angular-zzry1k?file=src%2Fapp%2Fapp.component.ts

    Regards

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels