Skip to content

Function to set value  #4

Description

@mprunell

When retrieving a complex object, the 'displayKey' attribute allows for showing that specific value when autocompleting.

When a typeahead entry is selected, typeahead.js triggers the "selected" event and passed the whole object.

I had to write the code below to make it work or the [object Object] label was shown on the input.

I'm wondering is this would be an improvement, or there is any other way of doing this better.

    if (value && ko.isObservable(value)) {
        if (displayedProperty) {
            value(suggestion[displayedProperty]);
        } else {
            value(suggestion);
        }
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions