matfish2 / vue-formular

a comprehensive vue.js form component
https://www.npmjs.com/package/vue-formular
MIT License
43 stars 11 forks source link

How to add a listener by event? #16

Closed JianiYang closed 7 years ago

JianiYang commented 7 years ago

I want to add a check to make sure user will save before exit. And I found that there is a vue-formular.change event might be useful , but i can't use it as a common VUE event .Is there any samples to use a event ?

JianiYang commented 7 years ago

Is there any way that can watch when the from's item value been changed?

matfish2 commented 7 years ago

As documented you can listen to a change event on any field. Say your field name is title:

this.$on('vue-formular.change::title', function(data) {

});
JianiYang commented 7 years ago

thanks ,but I want to know that how can I listen all sub-item of the from or I need to add the function one by one ?

matfish2 commented 7 years ago

Again, as documented, you can use the global vue-formular.change event, which is emitted for any field.