I use typeahead (0.10.1) in the application to return a list of clients using bloodhound prefetching. I cannot decide how to update / reinitialize the bloodhound with a new fingerprint, so that after a new client is inserted, it will use the new fingerprint and therefore enable the new client.
The system is ajax, so I can’t just change the name during the upgrade, I try to give it another fingerprint as shown in reinitializeclient () below, but it doesn’t work:
var clientthumbprint = "initialname";
var clients = new Bloodhound({
limit: 5,
prefetch:{
url: '/urltofeed/',
thumbprint:getthumbprint()
},
datumTokenizer: function(d) {
return Bloodhound.tokenizers.whitespace(d.label);
},
queryTokenizer: Bloodhound.tokenizers.whitespace
});
clients.initialize();
function reinitializeclient(newthumbprint){
clientthumbprint = newthumprint;
clients.initialize();
}
function getthumbprint(){
return clientthumbprint;
}
$('#search_user').typeahead({
minLength: 2,
},
{
displayKey: 'label',
source: clients.ttAdapter()
})
Anyone have any ideas what I'm doing wrong?
: head, pull, @jharding, reset, . :
function initialize_clients(){
clients = new Bloodhound({
limit: 5,
prefetch:{
url: '/pathtojson/',
thumbprint:getthumbprint()
},
datumTokenizer: function(d) {
return Bloodhound.tokenizers.whitespace(d.label);
},
queryTokenizer: Bloodhound.tokenizers.whitespace
});
clients.initialize();
};
function resetclients(){
clientthumbprint = 'somenewthumbprint';
clients.reset();
initialize_clients();
}
function getthumbprint(){
return clientthumbprint;
}