Open ppazos opened 5 years ago
This is an old post but here is a sample to get a list of tags via an AJAX call
$("#Tags").tokenfield({
delimiter: "|",
minLength: 1,
autocomplete: {
minLength: 2,
delay: 500,
source: function (request, response) {
$.ajax(
{
url: "YourUrlToGetTags"
dataType: "json",
data: {
searchTerm: request.term,
},
success: function (data) {
response(data);
}
});
}
}
});
The main problem of this solution when you want to use value/label pairs as token. You'll get a value list if you fill the field with a separator separated value list. How to sole this?
I can't find in the current documentation how can I set the autocomplete array dynamically from, for instance, an AJAX call to a backend service.
I need to provide a narrowed down list of possibilities since the amount of possible tags is about 10K! can't load that every time on the UI. Also I might need to show only 10-15 possible tags if the search on the server retrieves more than that to make the UI not show 100's of texts in the dropdown.
Is there some sample code on how to do this? Thanks a lot.