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

Initial label for remote #33

Open vanderlee opened 7 years ago

vanderlee commented 7 years ago

When using a remote source, the initial value does not display the labelProp value.

For example, this slightly modified demo with initial value 3 for the remoteHandler: http://jsfiddle.net/bvphzjvc/

Is it possible to call the source with the full value or perhaps some other method/trick to set the initial label?

rniemeyer commented 7 years ago

@vanderlee - If you know the label/value already, then you could set it directly:

this.remoteValue = ko.observable( { test: "initial-value", val: 3 } ); in the sample.

However, this would have to be the actual value until someone changed it. So, if a user did not make a change, then you would have to have code that checked if the value was an object rather than a number and grabbed the val (in this case).

I could see a change to this lib to look at an object provided in the dataValue option to try to determine the initial label value.

BHare1985 commented 6 years ago

I have this same issue. I think a change to the lib would be useful