Skip to content

Commit

Permalink
Filter checkbox: v-model item.checked
Browse files Browse the repository at this point in the history
  • Loading branch information
David Pashaev committed May 23, 2018
1 parent fc07972 commit 51796f8
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 12 deletions.
2 changes: 1 addition & 1 deletion filter-checkboxes/filter-checkboxes.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<input type="text" v-model="search">
<ul id="fruits">
<li v-for="item in filteredItems" :key="item.key">
<input type="checkbox" :value="item.key" :checked="item.checked" v-on:change="modify(item, $event)" /> {{ item.value }}
<input type="checkbox" :value="item.key" v-model="item.checked" /> {{ item.value }}
</li>
</ul>
</div>
Expand Down
11 changes: 0 additions & 11 deletions filter-checkboxes/filter-checkboxes.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,6 @@ window.addEventListener('load', function () {
? this.filterByValueMatch
: this.items;
}
},
methods: {
modify: function (item, event) {
var state = event.target.checked,
key = event.target.value,
index = item ? this.items.indexOf(item) : undefined;

if (item && !isNaN(index)) {
this.items[index].checked = state;
}
}
}
})
})

0 comments on commit 51796f8

Please sign in to comment.