Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Component as v-model modifiers not working #4204

Closed
projct1 opened this issue Nov 15, 2016 · 1 comment
Closed

Component as v-model modifiers not working #4204

projct1 opened this issue Nov 15, 2016 · 1 comment

Comments

@projct1
Copy link

projct1 commented Nov 15, 2016

Hi)

I have simple component:

<template>
    <div :class="[value && value.length > 2 ? 'has-success' : 'has-danger']">
        <input type="text"
               :class="['form-control', 'form-control-' + (value && value.length > 2 ? 'success' : 'danger')]"
               :placeholder="placeholder"
               :value="value"
               @change="change"
               @input="$emit('input', $event.target.value)">
    </div>
</template>

<script type="text/javascript">
    export default {
        props: ['placeholder', 'value'],
        methods: {
            change(e) {
                this.$emit('change', e.target.value);
            }
        }
    }
</script>

And call:

<input-text v-model.trim="who_took" @change="orderUpdate($event, 'who_took')"></input-text>

But .trim modifier dont working properly: class has-success sets even if value contains only spaces...

@projct1
Copy link
Author

projct1 commented Dec 10, 2016

Ok, thanks, but trim is not working after first initialization, i.e. on page load if input has two letters and one space, class will be set to 'has-success', though terms is this.value.length > 2
And this start working after i start typing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant