0

i'm using typeahead and i followed here and Typeahead insensitive accent but i cant succeed it and i dont understand where is my fault?

here is my js

        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 tels = new Bloodhound({
            datumTokenizer: Bloodhound.tokenizers.obj.whitespace('name'),
            queryTokenizer: queryTokenizer,
            limit: 10,
            prefetch: {
                url: 'assets/tels.json',
                filter: function (name) {
                    return $.map(tels,  function (name) {
                        // Normalize the name - use this for searching
                        var normalized = normalize(name);
                        return {
                            value: normalized,
                            // Include the original name - use this for display purposes
                            displayValue: name
                        };
                    })
                }
                }
        });
    tels.initialize();
 $('#the-basics').typeahead({
                hint: true,
                highlight: true,
                minLength: 2
            },
            {
                name: 'tels',
                displayKey: 'displayValue',
                source: tels.ttAdapter()
            });

thanks so much

Community
  • 1
  • 1
  • Are you getting any errors in the browser console? Can you give more detail on the problem you have? – Ben Smith Sep 21 '14 at 20:18
  • thanks for your response BenSmith. At the console of the firefox there's not any errors or anything. All i want to do is make something like [that](http://jsfiddle.net/Fresh/F3hG9/) . It works with local words with accents but when i try to do with json i can't do it. – édmond dantès Sep 24 '14 at 20:57
  • Can you add an example of your tels.json to the question? I can then check to see if your $.map is set-up correctly. – Ben Smith Sep 25 '14 at 00:06
  • [here is](http://www.flyingypsy.com/sample/) my raw sample with json. You can type "élancer, mêler, être" and [the other one](http://www.flyingypsy.com/sample/index2.html) which i tried to make accent folding – édmond dantès Sep 26 '14 at 09:02

0 Answers0