0

I want a function to be called using Vue when a user selects an option from a dropdown list. I've started with a really simple example, but i can't seem to get it to work. I have no console errors or errors highlighted in WebStorm, so i'm unsure where i'm going wrong.

Here's my code:

<template>
    <b-container>
        <b-row>
            <b-col>
                <div>
                    <b-dropdown id="ddown4" text="Product Type" class="m-md-2" v-on:change="FilterProduct">
                        <b-dropdown-item>4.5</b-dropdown-item>
                        <b-dropdown-item>10.5</b-dropdown-item>
                    </b-dropdown>
                </div>
            </b-col>
        </b-row>
    </b-container>
</template>

<script>

    export default {
        name: 'ProductFilters',
        methods:{
            FilterProduct(){
                alert('Yes!');
            }

        },
        data() {
            return {
            }
        }
    }
</script>
0

1 Answer 1

1

If you're listening for a native DOM event (one that is emitted by a regular HTML element, such as a select element, not a Vue component), you'll need to use the .native modifier ..

<b-dropdown id="ddown4" text="Product Type" class="m-md-2" v-on:change.native="FilterProduct">
Sign up to request clarification or add additional context in comments.

3 Comments

Thanks for the advice, and for directing me to .native, i hadn't seen that before, however this still isn't working for me.
@user3005003 It should work if the HTML element emitting the change event is the root element of your component. If not you'll need to use v-on="$listeners" on that element. You can read up on that here.
@user3005003 Another option would be to $emit a custom change event by your select element like this <select @change="$emit('change')" ...>.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.