lazy init edit submit btn and update demo link

This commit is contained in:
realaravinth
2021-07-26 11:49:07 +05:30
parent 8830961e04
commit 9bc11f3518
4 changed files with 51 additions and 49 deletions

View File

@@ -6,7 +6,8 @@
<. } .>
<. let level = levels.len() + 1; .>
<. include!("../add/add-level.html"); .>
<button data-sitekey="<.= key .>" class="sitekey-form__submit" type="submit">
<button data-sitekey="<.= key .>"
id="sitekey-form__submit" class="sitekey-form__submit" type="submit">
Submit
</button>
<. include!("../view/__form-bottom.html"); .>

View File

@@ -27,10 +27,12 @@ import {LEVELS} from '../add/ts/levels';
import getFormUrl from '../../../utils/getFormUrl';
import genJsonPayload from '../../../utils/genJsonPayload';
import createError from '../../../components/error';
import LazyElement from '../../../utils/lazyElement';
import VIEWS from '../../../views/v1/routes';
const BTN_CLASS = document.querySelector('sitekey-form__submit');
const BTN_ID = 'sitekey-form__submit';
const BTN = new LazyElement(BTN_ID);
const submit = async (e: Event) => {
e.preventDefault();
@@ -43,8 +45,7 @@ const submit = async (e: Event) => {
const levels = LEVELS.getLevels();
console.debug(`[form submition]: levels: ${levels}`);
const btn = <HTMLElement>document.querySelector(`${BTN_CLASS}`);
const key = btn.dataset.sitekey;
const key = BTN.get().dataset.sitekey;
const payload = {
levels,