March 10, 2013

trigger function from autocomplete input selection

Question by Bwyss

I have an input field that will autocomplete an address, I want an address selection to trigger a function.

html

Address: <input id="searchTextField" type="text" autocomplete="on" runat="server" />

JS

$('input[searchTextField]').bind('autocompleteSelect', function() {
  // some code...
});

I feel like I’m not anywhere close with the above…

Answer by Starx

I think you are trying to do this.

$("#searchTextField" ).autocomplete({
    change: function( event, ui ) {
        // The code you want after selection is made
    }
});

Author: Nabin Nepal (Starx)

Hello, I am Nabin Nepal and you can call me Starx. This is my blog where write about my life and my involvements. I am a Software Developer, A Cyclist and a Realist. I hope you will find my blog interesting. Follow me on Google+

...

Please fill the form - I will response as fast as I can!