Detect click on noSuggestion
Hi,
Is there a way to make the noSuggestionNotice selectable/clickable and have a callback ? The aim is to display "Create a new tag" for exemple so the user can select it and I can call a callback to handle new tag creation.
Right now I'm using transformResult and onSelect to create a fake result, but it would be nice and in my opinion make sens to able to use this noSuggestionNotice param to do so.
Thanks
After posting my question (with similar problem) to stack overflow( https://stackoverflow.com/questions/48973057/devbridge-autocomplete-howto-empty-search-field ) I found Your question. It seems, we're pointing in the same direction... I made another way: my AJAX route for getting the data from database sends also something like "make a new tag"- but my problem is the text in the searchfield stays the same... Could you explain how you "solved" or "bypassed" your problem with transformResult and onSelect? Thanks!
No problem, this is my approach :
transformResult: function (response, originalQuery) {
var suggestions = [];
response.data.forEach(function(item) {
suggestions.push({ value: item.name, data: item });
});
if (originalQuery.length > 1) {
suggestions.push({ value: originalQuery, data: null });
}
return { suggestions };
},
formatResult: function (suggestion, currentValue) {
if (suggestion.data === null) {
return "Create a new tag";
}
return suggestion.value;
},