I have this piece of code in my page :
var dataSourceUniques = new Bloodhound({
datumTokenizer: Bloodhound.tokenizers.obj.whitespace('uniqueName',
'baseItem'),
queryTokenizer: Bloodhound.tokenizers.whitespace,
prefetch: {
url: "uniques.json",
cache: false
}
});
How can I access keys and values in the prefetched json file without requesting it again? Like this:
function getValue() {
return dataSourceUniques['key']['value']
I got it working! I used the transform function and assigned the response to a globally available object.
var objects = {};
var dataSourceUniques = new Bloodhound({
datumTokenizer: Bloodhound.tokenizers.obj.whitespace('uniqueName', 'baseItem'),
queryTokenizer: Bloodhound.tokenizers.whitespace,
prefetch: {
url: "uniques.json",
cache: false,
transform: function(response) {
objects.uniquesObject = response;
return response;
}
}
});
Now I can do objects.uniquesObject['key']