tcrosen / twitter-bootstrap-typeahead

An extension of Twitter's Bootstrap Typeahead plugin with additional customisation.
MIT License
335 stars 161 forks source link

AJAX results should not be filtered? #32

Open carlosescri opened 11 years ago

carlosescri commented 11 years ago

I don't know if this is correct but, when I configure an AJAX call to give results to Typeahead it is supposed that results are filtered. As typeahead searchs for the querystring in the results If one of them hasn't it then it is not displayed.

query: 'asdf' # My database object has a field with that value
result: {id: 3, name: 'John Smith'} # Not displayed because 'asdf' is not contained in 'John Smith'

I know this is issue occurs because I'm using typeahead as a classic autocomplete, but I'm sure that other users are going to use it in the same way. I've fixed this in my results appending the field where the string was found, but it would be nice if we have an option for disabling filtering when using AJAX.

Cheers,

C.

brunowego commented 11 years ago

Try it...

        // Call the typeahead.
        $('#searchname').typeahead({
            ajax: {
                url: 'index.php?option=com_bolsas&task=pessoas.getname&tmpl=component&format=json',
                timeout: 300,
                method: 'get',
                triggerLength: 3,
                displayField: 'name',
                preDispatch: function (query) {
                    return {
                        nome: query
                    };
                }
            },
            display: 'name',
            val: 'id'
        });