0

everyone. I am trying to use an api which is by tom tom places autocomplete. there is a code as below:

    var ttSearchBox = new tt.plugins.SearchBox(tt.services, options);
    var searchBoxHTML = ttSearchBox.getSearchBoxHTML();
    $('#pickup_city').after(searchBoxHTML);

which generates a input field as below in my html code:

<input class="tt-search-box-input" placeholder="">

what i want to add an onchange argument to this input field like this:

  <input class="tt-search-box-input" placeholder="" onchange="myFunction()">

but i dont know how to do it? can anyone tell me how can i achhieve this?

here is the code from js :

 "getSearchBoxHTML", (function() {
            return n._container
        }))

and the n._container is :

n._container = document.createElement("div"), n._container.className = ".tt-search-box", 
 n._inputWrapper = new A(n._container, n.store, n.userActions), n._resultList = new 
 j(n._container, n.store, n.userActions), n._container

Thanks in advance <3

  • You can probably use [these answers](https://stackoverflow.com/questions/1628826/how-to-add-an-onchange-event-to-a-select-box-via-javascript) on your "searchBoxHTML" variable to get the effect you're looking for. This allows you to directly add the listener, instead of trying to DOM-get it by name, id, or whatever. – computercarguy May 13 '22 at 20:50
  • could you use the `loadingstarted` event? `ttSearchBox.on('tomtom.searchbox.loadingstarted', function(data) { console.log(data); });` – GrafiCode May 13 '22 at 20:54

0 Answers0