-
Notifications
You must be signed in to change notification settings - Fork 805
Open
Description
How to run tag-it and get the suggested values on button click?
Here is a fiddle: http://jsfiddle.net/rzL7uvpq/1/. I would like to get the suggested dropdown after button click.
<input id="input-newsearch">
<button class="btn btn-default btn-newsearch" id="search-newsearch" data-toggle="tooltip">Button</button>
$(document).ready(function () {
$("#input-newsearch").tagit({
singleField: true,
singleFieldDelimiter: ",",
allowSpaces: true,
autocomplete: ({
source: function( request, response ) {
response ( [ {
id: '56',
label: 'Name 01'
},
{ id: '68',
label: 'Name 02'
},
{ id: '49',
label: 'Name 03'
},
{ id: '40',
label: 'Name 04'
} ]
);
},
minLength: 3,
focus: function() {
return false;
},
html: true,
create: function(item) {
$(this).data('ui-autocomplete')._renderItem = function (ul, item) {
return $( "<li>" )
.append( "<a class='newsearch-label'>"+item.label+"</a>" )
.appendTo( ul );
};
$(this).data('ui-autocomplete')._renderMenu = function( ul, items ) {
var that = this;
$.each( items, function( index, item ) {
that._renderItemData( ul, item );
});
};
}
})
});
$(document).on('click','.btn-newsearch', function() {
console.log('Test');
//$('#input-newsearch').trigger("blur");
//$('#input-newsearch').trigger("click");
$('#input-newsearch').trigger("focus");
//$('#input-newsearch').autocomplete('search');
//$('#input-newsearch').autocomplete("search", "");
});
});
What am I missing?
SO: https://stackoverflow.com/questions/57513734/js-jquery-run-tag-it-on-button-click-not-working
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels