Autosuggest UI (without map) on clear callback

Silvia Rebelo 6 Reputation points
2021-02-07T11:43:08.27+00:00

I'm using the Microsoft.Maps.AutoSuggest module on my app and it's working great, however, I'm in the need of validating that the user has entered a value in order to continue. Imaging this scenario:

1) user searches for a location in the UI
2) selects one from the list (I save this in a state variable)
3) the user "clears" the selection clicking the "x" icon (I need to clear the state here)

I've been reading the documentation and I can't find a callback for that clear event.

I tried to programatically clearing the state variable with an onChange function in the input, but I'm introducing an error and I'm just hoping there is a way to do this with the module callbacks?

window.Microsoft.Maps.loadModule('Microsoft.Maps.AutoSuggest', {
      callback: onLoad,
      errorCallback: onError,
      clearCallback: onClear   // <----- something like this?
});

Any idea how this could be achieved? Thanks in advance!

Windows Maps
Windows Maps
A Microsoft app that provides voice navigation and turn-by-turn driving, transit, and walking directions.
243 questions
{count} vote

2 answers

Sort by: Most helpful
  1. IoTGirl 2,971 Reputation points Microsoft Employee
    2021-02-11T18:25:22.71+00:00
    1 person found this answer helpful.
    0 comments No comments

  2. lenrok 6 Reputation points
    2021-02-25T02:57:44.607+00:00

    @Silvia Rebelo try:

    $('input[type=search]').on('search', function () {  
        console.log("clear clicked");  
    });  
    
    1 person found this answer helpful.
    0 comments No comments