jquery UI, Bootstrap 3 and bootstrap-tokenfield are not working with ajax.
The local source example bellow works:
$('.Subject-PreRequisites').tokenfield({
autocomplete: {
source: ['Amsterdam', 'Washington', 'Sydney', 'Beijing', 'Cairo'],
delay: 100
},
showAutocompleteOnFocus: true
});
But when I introduce the ajax call like:
$('.Subject-PreRequisites').tokenfield({
autocomplete: {
source: $.get(getallsubjectsUrl, function(data) {
return data;
}, 'json'),
delay: 100
},
showAutocompleteOnFocus: true
});
Than I tough it would be a problem with the timing, so I modified it a bit:
var sourceTokens = '';
$.get(getallsubjectsUrl, function(data) {
sourceTokens = data;
}, 'json')
.done(function() {
$('.token-input-dropdown').tokenfield({
autocomplete: {
source: sourceTokens,
delay: 100
},
showAutocompleteOnFocus: true
});
});
And even the correct source is assigned, the dropdown is not shown.
Is there any other option for bootstrap 3 to have this same functionality ? I saw a possible solution, but it's link is broken. If not, how to fix that ?