Search code examples
typeahead.jsbootstrap-tags-input

Bootstrap tags input caching data


I am using boostrap tags input with typeahead js. but the data are not updated after updating database.

I am using a service in my app to provide data.

Regards.

Here the code i am using :

        var citynames = new Bloodhound({
        datumTokenizer: Bloodhound.tokenizers.obj.whitespace('name'),
        queryTokenizer: Bloodhound.tokenizers.whitespace,
        prefetch: {
        url: '@Url.Action("GetTagsJson", "Tags")',
            filter: function (list) {
                return $.map(list, function (cityname) {
                    return { name: cityname };
                });
                }
            }
        });

    citynames.initialize();

    $('#userTags').tagsinput({
        typeaheadjs: [{
            minLength: 1,
            highlight: true
        }, {
            minLength: 1,
            name: 'citynames',
            displayKey: 'name',
            valueKey: 'name',
            source: citynames.ttAdapter()
            }],
        freeInput: true
    });

Solution

  • citynames.clearPrefetchCache();
    citynames.initialize(true);
    

    use this .it will clear cache on load and new data will be updated