Reputation: 128
I have a text box when i start typing it gives a ajax cal and i will have some suggestions in it. now, when i select an option from that autosuggest, is there any event so that i can capture that selected option in js file so that i can continue.
i tried,
this one gives nothing,
$("#searchPin").select(function() {
var pin = $("#searchPin").val()
alert(pin)
});
and i used change event but it just capturing the text which i written in the text box not the one which i selected from ajax call drop down. any ideas?
Upvotes: 0
Views: 135
Reputation: 3783
You can use the blur
event, it fires when the user leaves the textbox.
Edit, since this is the jquery ui plugin.
You can make use of the select function, it is triggered when an item is selected from the menu. The default action is to replace the text field's value with the value of the selected item. jquery ui doc
$( ".selector" ).autocomplete({
select: function( event, ui ) {}
});
Upvotes: 1
Reputation: 207557
jQuery UI autocomplete's documentation lists events that it fires. Use the API.
$( ".selector" ).on( "autocompleteselect", function( event, ui ) {} );
Upvotes: 1