I'm using JQuery Autocomplete to return X1 value
$( "#autocomplete" )
// don't navigate away from the field on tab when selecting an item
.bind( "keydown", function( event ) {
if ( event.keyCode === $.ui.keyCode.TAB &&
$( this ).data( "autocomplete" ).menu.active ) {
event.preventDefault();
}
})
.autocomplete({
minLength: 0,
source: function( request, response ) {
// delegate back to autocomplete, but extract the last term
response( $.ui.autocomplete.filter(
X1, extractLast( request.term ) ) );
},
focus: function() {
// prevent value inserted on focus
return false;
},
select: function( event, ui ) {
var terms = split( this.value );
// remove the current input
terms.pop();
// add the selected item
terms.push( ui.item.value );
// add placeholder to get the comma-and-space at the end
terms.push( "" );
this.value = terms.join( " " );
return false;
}
});
However, I want X1 values to show only if the user start typing a text that is equal to the array below:
var stt_start = [
"I am intrested",
"it is",
]
I also added the below code to check while the user is typing if the text is equal to the array stt_start
$("#autocomplete").keyup(function(event) {
var stt=$(this).val();
if($.inArray(stt, stt_start) > -1){
var found = 1;
// show X1 values from JQuery Autocomplete
}
});
I added the check code in different places in the JQuery Autocomplete but it didn't work !
Could anyone guide me where to add this condition so X1 values will start to appear after the user typed one of the text in stt_start.
Aucun commentaire:
Enregistrer un commentaire