rniemeyer / knockout-jqAutocomplete

knockout-jqAutocomplete is a Knockout.js plugin designed to work with jQuery UI's autocomplete widget.
MIT License
49 stars 20 forks source link

options.value is not a function #18

Closed JasonColeyNZ closed 8 years ago

JasonColeyNZ commented 8 years ago

If I type in characters, use arrow up down to select then press tab (to go to the next field in my form) the below code is giving me an error (at lines 62-75). options.value is the actual value set to the autocomplete in initialization.

        //user made a change without selecting a value from the list
        config.change = function (event, ui) {
            if (!ui.item || !ui.item.actual) {
                options.value(event.target && event.target.value);

                if (ko.isWriteableObservable(options.dataValue)) {
                    options.dataValue(null);
                }
            }

            if (existingChange) {
                existingChange.apply(this, arguments);
            }
        };

my viewmodel looks like..

self.VendorList = function (searchTerm, callback) { $.ajax({ url: urlAutoCompleteVendor, type: "POST", dataType: "json", data: { term: searchTerm }, success: function (data) { callback($.map(data, function (item) { return { ShortName: item.ShortName, Id: item.Id }; })) }, error: function (XMLHttpRequest, textStatus, errorThrown) { alert('error occurred while autocomplete') } }) }

and binding ...

JasonColeyNZ commented 8 years ago

Ahh my bad, I had an incorrect Id binding...sorry