Reputation: 44086
I am using this autocomplete Plugin which works great but the problem is
$('#request_song').autocomplete({
serviceUrl: '<%= ajax_path("trackName") %>',
minChars:1,
width: 300,
delimiter: /(,|;)\s*/,
deferRequestBy: 0, //miliseconds
params: { artists: 'Yes' },
});
<div class="field">
<label for="request_song">Song</label><br />
<input id="request_song" name="request[song]" size="30" type="text" />
</div>
This works well but is there a callback or something that will tell me when its complete and someone selected something. I basically want to show a div thats currently hidden on the page or call an action via ajax to get some info.. But how do i know when someone selected soemthing. I was thinking of seeing if the textbox losses focus but I dont know the syntax for that and I was thinking there should be a better way to do that with this plugin or Jquery
Upvotes: 0
Views: 1290
Reputation: 11812
USE ONSELECT event
$('#request_song').autocomplete({
serviceUrl: '<%= ajax_path("trackName") %>',
minChars:1,
width: 300,
delimiter: /(,|;)\s*/,
deferRequestBy: 0, //miliseconds
params: { artists: 'Yes' },
onselect: function(value, data){
//DO SOMETHING HERE
}
});
Upvotes: 1