Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Typeahead.js only matches beginning of the word #857

Closed
vaclavgreif opened this issue May 24, 2014 · 2 comments
Closed

Typeahead.js only matches beginning of the word #857

vaclavgreif opened this issue May 24, 2014 · 2 comments

Comments

@vaclavgreif
Copy link

I'm using a code very similar to the examples:

var events = new Bloodhound({
    datumTokenizer: Bloodhound.tokenizers.obj.whitespace('name'),
    queryTokenizer: Bloodhound.tokenizers.whitespace,
    limit: 100,
    prefetch: {
        url: Ajax.pluginurl + 'json/events.json',
        ttl: 1
    }
});

events.initialize();

initialize_events_typeahead ();

function initialize_events_typeahead () {
    $('.event_name').typeahead(null, {
        name: 'event',
        displayKey: 'name',
        source: events.ttAdapter(),
        templates: {
            empty: [
                '<div class="empty-message">',
                Ajax.no_results_found,
                '</div>'
            ].join('\n'),
            suggestion: function(data){
                return '<p><strong>' + data.name + '</strong> - ' + data.description + '</p>';
            }
        },
        engine: Hogan
    });

However, this code matches only the beginning of the words, while in the examples it matches also the middle of the words.

Am I missingf something? I also created a stackoverflow question, with answer explaining what's going on: http://stackoverflow.com/questions/23448193/typeahead-js-only-matches-beginning-of-the-word/23619380

@SirZach
Copy link

SirZach commented Jun 10, 2014

I have written failing unit tests to prove this. Modifying the search algorithm to make it work for searching in the middle of words however is beyond the scope of what I'm comfortable with unless someone from the core team wants to provide advice or confirmation that this is something that should be done.

@jharding
Copy link
Contributor

jharding commented Jul 9, 2014

Duplicate of #525.

@jharding jharding closed this as completed Jul 9, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

3 participants