corejavascript / typeahead.js

typeahead.js is a fast and fully-featured autocomplete library
https://typeahead.js.org/
MIT License
963 stars 231 forks source link

Highest hit on top, even with multiple sources? #177

Open notflip opened 6 years ago

notflip commented 6 years ago

I'm getting the following result when using multiple sources (and bloodhound). Is there anyway I can get it to the top? So that the results are not sorted by group but by biggest hit?

screen shot 2018-01-04 at 15 18 45

This is my current code.

$(".global-search input").typeahead({
    hint: true,
    highlight: true,
    minLength: 2,
    maxItem: 30,
    dynamic: true,
}, {
    source: suppliersEngine.ttAdapter(),
    name: 'suppliers',
    templates: {
        suggestion: function (data) {
            return '<a class="list-group-item" href="#"><span class="name">'+ data.name + '</span> <small class="pull-right">Suppliers</small></a>';
        }
    }
}, {
    source: recipesEngine.ttAdapter(),
    name: 'recipes',
    templates: {
        suggestion: function (data) {
            return '<a class="list-group-item" href="#"><span class="name">'+ data.name + '</span> <small class="pull-right">Recipes</small></a>';
        }
    }
}, {
    source: preparationsEngine.ttAdapter(),
    name: 'preparations',
    templates: {
        suggestion: function (data) {
            return '<a class="list-group-item" href="#"><span class="name">'+ data.name + '</span> <small class="pull-right">Preparations</small></a>';
        }
    }
});

Any help would be greatly appreciated!

PascalMagnard commented 6 years ago

+1