Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Awesomplete - get selected text

Is there a straightforward way to get the text in an awesomplete field (https://leaverou.github.io/awesomplete/)?

var input = document.getElementById("inputlist");
alert(input.value);

shows NaN!

like image 992
S_S Avatar asked Mar 14 '23 00:03

S_S


1 Answers

You need to add the event either awesomplete-select or awesomplete-selectcomplete

In regular Javascript

var input = document.getElementById("inputlist"); 
new Awesomplete(input, {list: yourlist});
document.getElementById('inputlist').addEventListener('awesomplete-selectcomplete',function(){
  alert(this.value); 
});  

In Jquery

var input=$("#inputlist")[0];
new Awesomplete(input, {list: yourlist});
$("#inputlist").on('awesomplete-selectcomplete',function(){
  alert(this.value);
});
like image 157
Jagadeesh.c Avatar answered Mar 23 '23 11:03

Jagadeesh.c