Skip to content

Commit 17b5e2d

Browse files
committed
docs(checkbox): update reference name
1 parent 726e060 commit 17b5e2d

File tree

4 files changed

+24
-25
lines changed

4 files changed

+24
-25
lines changed

static/usage/v8/checkbox/helper-error/demo.html

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,27 +31,27 @@
3131

3232
<script>
3333
const form = document.getElementById('my-form');
34-
const checkbox = form.querySelector('ion-checkbox');
34+
const agree = form.querySelector('ion-checkbox');
3535

3636
form.addEventListener('submit', (event) => submit(event));
37-
checkbox.addEventListener('ionChange', (event) => validateCheckbox(event));
37+
agree.addEventListener('ionChange', (event) => validateCheckbox(event));
3838

3939
const validateCheckbox = (event) => {
40-
checkbox.classList.add('ion-touched');
40+
agree.classList.add('ion-touched');
4141

4242
if (!event.detail.checked) {
43-
checkbox.classList.add('ion-invalid');
44-
checkbox.classList.remove('ion-valid');
43+
agree.classList.add('ion-invalid');
44+
agree.classList.remove('ion-valid');
4545
} else {
46-
checkbox.classList.remove('ion-invalid');
47-
checkbox.classList.add('ion-valid');
46+
agree.classList.remove('ion-invalid');
47+
agree.classList.add('ion-valid');
4848
}
4949
};
5050

5151
const submit = (event) => {
5252
event.preventDefault();
5353

54-
validateCheckbox({ detail: { checked: checkbox.checked } });
54+
validateCheckbox({ detail: { checked: agree.checked } });
5555
};
5656
</script>
5757
</body>

static/usage/v8/checkbox/helper-error/javascript.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,27 +11,27 @@
1111

1212
<script>
1313
const form = document.getElementById('my-form');
14-
const checkbox = form.querySelector('ion-checkbox');
14+
const agree = form.querySelector('ion-checkbox');
1515
1616
form.addEventListener('submit', (event) => submit(event));
17-
checkbox.addEventListener('ionChange', (event) => validateCheckbox(event));
17+
agree.addEventListener('ionChange', (event) => validateCheckbox(event));
1818
1919
const validateCheckbox = (event) => {
20-
checkbox.classList.add('ion-touched');
20+
agree.classList.add('ion-touched');
2121
2222
if (!event.detail.checked) {
23-
checkbox.classList.add('ion-invalid');
24-
checkbox.classList.remove('ion-valid');
23+
agree.classList.add('ion-invalid');
24+
agree.classList.remove('ion-valid');
2525
} else {
26-
checkbox.classList.remove('ion-invalid');
27-
checkbox.classList.add('ion-valid');
26+
agree.classList.remove('ion-invalid');
27+
agree.classList.add('ion-valid');
2828
}
2929
};
3030
3131
const submit = (event) => {
3232
event.preventDefault();
3333
34-
validateCheckbox({ detail: { checked: checkbox.checked } });
34+
validateCheckbox({ detail: { checked: agree.checked } });
3535
};
3636
</script>
3737
```

static/usage/v8/checkbox/helper-error/react.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ function Example() {
66
const [isTouched, setIsTouched] = useState<boolean>(false);
77
const [isValid, setIsValid] = useState<boolean | undefined>();
88

9-
const checkboxRef = useRef<HTMLIonCheckboxElement>(null);
9+
const agreeRef = useRef<HTMLIonCheckboxElement>(null);
1010

1111
const validateCheckbox = (event: CheckboxCustomEvent<{ checked: boolean }>) => {
1212
setIsTouched(true);
@@ -16,8 +16,8 @@ function Example() {
1616
const submit = (event: React.FormEvent<HTMLFormElement>) => {
1717
event.preventDefault();
1818

19-
if (checkboxRef.current) {
20-
validateCheckbox({ detail: { checked: checkboxRef.current.checked } } as CheckboxCustomEvent<{
19+
if (agreeRef.current) {
20+
validateCheckbox({ detail: { checked: agreeRef.current.checked } } as CheckboxCustomEvent<{
2121
checked: boolean;
2222
}>);
2323
}
@@ -27,7 +27,7 @@ function Example() {
2727
<>
2828
<form onSubmit={submit}>
2929
<IonCheckbox
30-
ref={checkboxRef}
30+
ref={agreeRef}
3131
className={`${isValid ? 'ion-valid' : ''} ${isValid === false ? 'ion-invalid' : ''} ${
3232
isTouched ? 'ion-touched' : ''
3333
}`}

static/usage/v8/checkbox/helper-error/vue.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<template>
33
<form id="my-form" @submit.prevent="submit">
44
<ion-checkbox
5-
v-model="isChecked"
5+
v-model="agree"
66
helper-text="This needs to be checked"
77
error-text="This field is required"
88
@ionChange="validateCheckbox"
@@ -27,7 +27,7 @@
2727
IonButton,
2828
},
2929
setup() {
30-
const isChecked = ref(false);
30+
const agree = ref(false);
3131
const isTouched = ref(false);
3232
const isValid = ref<boolean | undefined>();
3333
@@ -37,12 +37,11 @@
3737
};
3838
3939
const submit = () => {
40-
isTouched.value = true;
41-
isValid.value = isChecked.value;
40+
validateCheckbox({ detail: { checked: agree.value } } as CheckboxCustomEvent<{ checked: boolean }>);
4241
};
4342
4443
return {
45-
isChecked,
44+
agree,
4645
isTouched,
4746
isValid,
4847
validateCheckbox,

0 commit comments

Comments
 (0)