Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Initial content of typeahead v-model not displayed #231

Closed
DonMartin76 opened this issue Jul 23, 2018 · 4 comments
Closed

Initial content of typeahead v-model not displayed #231

DonMartin76 opened this issue Jul 23, 2018 · 4 comments
Assignees
Labels

Comments

@DonMartin76
Copy link

DonMartin76 commented Jul 23, 2018

When binding a typeahead component instance to an existing v-model, the current value of the v-model property doesn't seem to be propagated to the input field; if a new value is typed in, or if the view model is changed from the outside, everything is propagated correctly. It's just the initial value which does not make it into the input field.

Version & browser

0.25.0, Safari and Chrome on macOS 0.13.5

Which component

Typeahead

Steps to reproduce the problem

Here, standardClaims is the following list:

const standardClaims = [
            "sub",
            "name",
            "given_name",
            "family_name",
            "middle_name",
            "nickname",
            "preferred_username",
            "profile",
            "picture",
            "website",
            "email",
            "email_verified",
            "gender",
            "birthdate",
            "zoneinfo",
            "locale",
            "phone_number",
            "phone_number_verified"
        ];

Then the code which does not work is the following; "does not work" in the sense that the pre-populated value of oidcClaim is not displayed in the input field.

<input id="aninput" class="form-control" type="text" placeholder="Specify claim name..." />
<typeahead v-model="oidcClaim" :target="#aninput" :data="standardClaims" />

Expected behavior

The value of the property referenced in v-model is written into the input field initially.

Actual behavior

The input field is always empty.

Thanks for your awesome work!

@wxsms wxsms self-assigned this Jul 23, 2018
@wxsms wxsms added the bug label Jul 23, 2018
@wxsms
Copy link
Member

wxsms commented Jul 23, 2018

Thanks for filling this issue. you may use mounted hook to assign v-model as a workaround for now.

@DonMartin76
Copy link
Author

Thanks for the heads-up, using mounted to prepopulate the input elements worked fine.

@DonMartin76
Copy link
Author

Except when adding things to an array dynamically, where the typeahead element displays part of the dynamically added content (using this.value.someArray.push(...)... But I can live with that.

@kyleweishaupt
Copy link

I'm having a similar issue with an edit screen. I need to wait for an ajax request to get the data and then apply it to the v-model used on the typeahead, but can't seem to get it to populate the textbox. The ajax function is even called in the component's mounted() method.

@wxsms wxsms closed this as completed in aecc2ac Jul 31, 2018
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants