0

I am using django with bloodhound in prefetch mode like in the official example.

    jQuery(document).ready(function() {
    var countries = new Bloodhound({
      datumTokenizer: Bloodhound.tokenizers.whitespace,
      queryTokenizer: Bloodhound.tokenizers.whitespace,
      // url points to a json file that contains an array of country names, see
      // https://github.com/twitter/typeahead.js/blob/gh-pages/data/countries.json
      prefetch: '../static/data/countries.json'
    });

    // passing in `null` for the `options` arguments will result in the default
    // options being used
    var typeahead_elem = $('.typeahead');
    typeahead_elem.typeahead({
      name: 'countries',
      source: countries
    });
})

The difference with the official example is the url. I use '../static/data/countries.json' But I know by checking the server and using firebug network tab that no request is sent. WHEREAS (and now it becomes strange) if I use '../data/countries.json'. Then the request is sent and becomes a 404. But with firebug I can edit it and resend. And putting '../static/data/countries.json' works, it comes back code 304.

Why is my original '../static/data/countries.json' not sent ??

Btw, why is 'countries.initialize();' not needed ?

Proph73
  • 37
  • 1
  • 5

0 Answers0