This is a question based on: Trying to get tag-it to work with an AJAX call
However the above just creates an error message of 'this.source is not a function' for me.
I am trying to get this json list to appear as the tag source for tagit via ajax. Code below:
// Tagit
$("#tags").tagit({
tagSource: function() {
$.ajax({
url: "/admin/ajax.php?q=fetch_all_tags",
dataType: "json",
success: function(data) {
console.log(data);
return data;
}
});
}
});
The ajax call returns:
{"4":"php","2":"html","3":"css"}
Check out this code may help you
$("#mytags").tagit({
autocomplete: {
source: function( request, response ) {
/*call api*/
}
}
});
The autocomplete.source should be overridden if you want to use custom autocompletion sources, like an Ajax / XHR response.
For example:
$("#myTags").tagit({
autocomplete: {
delay: 0,
minLength: 2,
source : 'your data response'
}
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With