0

Racking my brains here hoping for some help. I have successfully implemented bootstrap 3 typeahead (https://github.com/bassjobsen/Bootstrap-3-Typeahead) and it is showing suggestions from my JSON as expected.

 var employer = new Bloodhound({
    datumTokenizer: Bloodhound.tokenizers.whitespace,
    queryTokenizer: Bloodhound.tokenizers.whitespace,
    remote: {
        url: "/employers.json",
        cache: "false"}
    });

    employer.initialize();

    $("#employer").typeahead({
        source:employer.ttAdapter()
    });

However the issue I have is whenever I add a new item to the JSON, it does not appear in the suggestions. I am guessing that it caches the results as I can see the new entries in incognito mode!

I need this list to be live - I already have a script which adds entries to the JSON everytime the form is submitted and I need the new entry to be available for the next form submission.

Any help would be appreciated.

user3163357
  • 129
  • 3
  • 10

1 Answers1

1

Got a solution if it helps anyone. Removed bloodhound and just done a straight ajax call with cache set to false. Work perfectly :)

   $.ajax({
            type: 'POST',
            url: '/employers.json',
            cache: false,
            success: function(data) {
                $('#employer').typeahead({source: data});
            }
             });
user3163357
  • 129
  • 3
  • 10