src/includes/suggestions.js
function () {
        var that = this,
            fullQuery = that.extendedCurrentValue(),
            currentValue = that.el.val(),
            resolver = $.Deferred();

        resolver
            .done(function (suggestion) {
                that.selectSuggestion(suggestion, 0, currentValue, { hasBeenEnriched: true });
                that.el.trigger('suggestions-fixdata', suggestion);
            })
            .fail(function () {
                that.selection = null;
                that.el.trigger('suggestions-fixdata');
            });

        if (that.isQueryRequestable(fullQuery)) {
            that.currentValue = fullQuery;
            that.getSuggestions(fullQuery, { count: 1, from_bound: null, to_bound: null })
                .done(function (suggestions) {
                    // data fetched
                    var suggestion = suggestions[0];
                    if (suggestion) {
                        resolver.resolve(suggestion);
                    } else {
                        resolver.reject();
                    }
                })
                .fail(function () {
                    // no data fetched
                    resolver.reject();
                });
        } else {
            resolver.reject();
        }
    }
function () {
        var that = this,
            fullQuery = that.extendedCurrentValue(),
            currentValue = that.el.val(),
            resolver = $.Deferred();

        resolver
            .done(function (suggestion) {
                that.selectSuggestion(suggestion, 0, currentValue, { hasBeenEnriched: true });
                that.el.trigger('suggestions-fixdata', suggestion);
            })
            .fail(function () {
                that.selection = null;
                that.el.trigger('suggestions-fixdata');
            });

        if (that.isQueryRequestable(fullQuery)) {
            that.currentValue = fullQuery;
            that.getSuggestions(fullQuery, { count: 1, from_bound: null, to_bound: null })
                .done(function (suggestions) {
                    // data fetched
                    var suggestion = suggestions[0];
                    if (suggestion) {
                        resolver.resolve(suggestion);
                    } else {
                        resolver.reject();
                    }
                })
                .fail(function () {
                    // no data fetched
                    resolver.reject();
                });
        } else {
            resolver.reject();
        }
    }
function ( ) { var that = this , fullQuery = that . extendedCurrentValue ( ) , currentValue = that . el . val ( ) , resolver = $ . Deferred ( ) ; resolver . done ( function ( suggestion ) { that . selectSuggestion ( suggestion , 0 , currentValue , { hasBeenEnriched : true } ) ; that . el . trigger ( 'suggestions-fixdata' , suggestion ) ; } ) . fail ( function ( ) { that . selection = null ; that . el . trigger ( 'suggestions-fixdata' ) ; } ) ; if ( that . isQueryRequestable ( fullQuery ) ) { that . currentValue = fullQuery ; that . getSuggestions ( fullQuery , { count : 1 , from_bound : null , to_bound : null } ) . done ( function ( suggestions ) { // data fetched var suggestion = suggestions [ 0 ] ; if ( suggestion ) { resolver . resolve ( suggestion ) ; } else { resolver . reject ( ) ; } } ) . fail ( function ( ) { // no data fetched resolver . reject ( ) ; } ) ; } else { resolver . reject ( ) ; } }
Fetch full object for current INPUT's value
if no suitable object found, clean input element
Fetch full object for current INPUT s value if no suitable object found clean input element