Skip to content
This repository has been archived by the owner on Dec 25, 2017. It is now read-only.

Commit

Permalink
fix(checkbox): fix v-model is not work
Browse files Browse the repository at this point in the history
Closes #153
  • Loading branch information
kazupon committed Feb 3, 2016
1 parent 1c88eca commit caed1c8
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/directives/validate.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,19 @@ export default function (Vue) {

this.onBlur = _.bind(validation.listener, validation)
_.on(el, 'blur', this.onBlur)
if ((el.type === 'checkbox'
|| el.type === 'radio'
if ((el.type === 'radio'
|| el.tagName === 'SELECT') && !model) {
this.onChange = _.bind(validation.listener, validation)
_.on(el, 'change', this.onChange)

} else if (el.type === 'checkbox') {
if (!model) {
this.onChange = _.bind(validation.listener, validation)
_.on(el, 'change', this.onChange)
} else {
this.onClick = _.bind(validation.listener, validation)
_.on(el, 'click', this.onClick)
}
} else {
if (!model) {
this.onInput = _.bind(validation.listener, validation)
Expand All @@ -108,6 +116,11 @@ export default function (Vue) {
this.onInput = null
}

if (this.onClick) {
_.off(el, 'click', this.onClick)
this.onClick = null
}

if (this.onChange) {
_.off(el, 'change', this.onChange)
this.onChange = null
Expand Down

0 comments on commit caed1c8

Please sign in to comment.