0

Using TypeAhead 0.10.4, I want to display a non-selectable message when no results are found by a query. How do I do this? I've tried adding typeahead-no-results to my input control but that doesnt seem to work

<input  type="text" runat="server" id="addressTypeAhead"  typeahead-no-results="No address found">



$('.typeahead').on('typeahead:selected', function (evt, item) {
        // set hidden var
        $('*[data-name="addressId"]').val(item.identifier);
    })

    // Instantiate the Typeahead UI
    $('.typeahead').typeahead({ minLength: 3 }, {
        displayKey: 'value',
        valueKey: 'identifier',
        items: 5,
        source: addresses.ttAdapter()
    });

I'm getting addresses from Bloodhound elsewhere

1 Answer 1

1

This worked for me:

$('.typeahead').typeahead({ minLength: 3 }, {
    ....
    source: addresses.ttAdapter(), templates: {
        empty: '<div class="tt-no-result">No results found.</div>'
    }
});

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.