init 6
This commit is contained in:
parent
f9c6ea0726
commit
dce2713f4b
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
<!-- Basic Page Needs –––––––––––––––––––––––––––––––––––––––––––––––––– -->
|
<!-- Basic Page Needs –––––––––––––––––––––––––––––––––––––––––––––––––– -->
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<title>Your page title here :)</title>
|
<title>Steam Workshop Viewer</title>
|
||||||
<meta name="description" content="">
|
<meta name="description" content="">
|
||||||
<meta name="author" content="">
|
<meta name="author" content="">
|
||||||
|
|
||||||
@ -55,7 +55,7 @@
|
|||||||
<template x-for="item in items" :key="item.id">
|
<template x-for="item in items" :key="item.id">
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<input type="checkbox" x-on:click="checkItem" x-model="checkedItems" x-bind:value="item" class="checkbox"/>
|
<input type="checkbox" x-model="checkedItems" x-bind:value="item.id" class="checkbox" />
|
||||||
</td>
|
</td>
|
||||||
<td x-text="item.id"></td>
|
<td x-text="item.id"></td>
|
||||||
<td x-text="item.title"></td>
|
<td x-text="item.title"></td>
|
||||||
|
|||||||
12
src/index.js
12
src/index.js
@ -16,22 +16,12 @@ document.addEventListener('alpine:init', () => {
|
|||||||
items: [],
|
items: [],
|
||||||
loading: false,
|
loading: false,
|
||||||
checkedItems: [],
|
checkedItems: [],
|
||||||
checkItem(e) {
|
|
||||||
let checkedItem = e.target.value;
|
|
||||||
console.log('checkedItem', checkedItem);
|
|
||||||
|
|
||||||
let checkbox = document.querySelectorAll('.checkbox').find(cb => cb.value === checkedItem.id);
|
|
||||||
checkbox.checked = e.target.checked;
|
|
||||||
|
|
||||||
console.log(this.checkedItems);
|
|
||||||
},
|
|
||||||
checkItems(e) {
|
checkItems(e) {
|
||||||
if (e.target.checked) {
|
if (e.target.checked) {
|
||||||
this.checkedItems = this.items;
|
this.checkedItems = this.items.map(item => item.id);
|
||||||
} else {
|
} else {
|
||||||
this.checkedItems = [];
|
this.checkedItems = [];
|
||||||
}
|
}
|
||||||
console.log(this.checkedItems);
|
|
||||||
},
|
},
|
||||||
async getModDescription() {
|
async getModDescription() {
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user