I want to disable accent sensitivity in my typeahead . So i'm using this code :
<script>
var charMap = {
"à": "a",
"á": "a",
"â": "a",
"é": "e",
"è": "e",
"ê": "e",
"ë": "e",
"É": "e",
"ï": "i",
"î": "i",
"ô": "o",
"ö": "o",
"û": "u",
"ù": "u",
"ü": "u",
"ñ": "n"
};
var normalize = function (input) {
$.each(charMap, function (unnormalizedChar, normalizedChar) {
var regex = new RegExp(unnormalizedChar, 'gi');
input = input.replace(regex, normalizedChar);
});
return input;
};
var queryTokenizer = function (q) {
var normalized = normalize(q);
return Bloodhound.tokenizers.whitespace(normalized);
};
var tags = new Bloodhound({
datumTokenizer: Bloodhound.tokenizers.obj.whitespace('name'),
queryTokenizer: queryTokenizer,
prefetch: {
url: '{{URL}}',
filter: function(list) {
return $.map(list, function(tag) {
var normalized = normalize(tag);
return { name: normalized }; });
}
}
});
</script>
I got this error in the console :
TypeError: input is null
ps : without using this normalize method .. my code works good