8

I have a problem with event listener for input radio.

HTML:

<input
  type="radio"
  id="flat"
  name="property_type"
  class="switch-input"
  v-model="registerData.propertyType"
  value="flat"
  checked
/>

And when I add v-on="change:foo" into input element, the page crash loading on that input radio.

Code:

var companyList = new Vue({
    el: '#companyList',
    cache: false,
    data: {
        disabledTime: {
            to: new Date()
        },
        registerData: {
            serviceCategoryId: '{{ $serviceCategoryId }}'
        }
    },
    methods: {
        foo: function() {
            console.log('aaa');
        }
    },
})

What is the best way to call function on change event?

1
  • what version of vuejs are you using? Commented May 3, 2017 at 23:57

1 Answer 1

20

Assuming you're using vuejs 2, your syntax is incorrect, this is actually vuejs 1 syntax.

v-on:change="foo" is the correct syntax, check the docs for more details.

Sign up to request clarification or add additional context in comments.

1 Comment

works flawlessly!

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.