Add ability to set SELECT values
This commit is contained in:
@@ -10,6 +10,13 @@
|
||||
<p>$textinterp</p>
|
||||
<button title="$title" data-e6d-event-click="click buttonclick">A button with tooltip and onclick $textinterpfunc</button>
|
||||
<p>Oh, look: a normal dollar sign: $. And then a dollar sign with no vars (does not resolve, emits error): $dollar</p>
|
||||
<label>This should autoselect to 3</label>
|
||||
<select data-e6d-value="$selectval">
|
||||
<option value="one">1</option>
|
||||
<option value="two">2</option>
|
||||
<option value="three">3</option>
|
||||
<option value="four">4</option>
|
||||
</select>
|
||||
</div>
|
||||
</template>
|
||||
<main>
|
||||
@@ -40,6 +47,7 @@
|
||||
},
|
||||
title: `A title, injected`,
|
||||
dynamicInterp: document.getElementById(`text-interp`).value,
|
||||
selectval: `three`,
|
||||
});
|
||||
document.getElementById(`template-add`).appendChild(bind);
|
||||
};
|
||||
|
||||
@@ -67,10 +67,16 @@ class TemplateE6d extends HTMLTemplateElement {
|
||||
} else {
|
||||
const textTemplate = buildTextTemplate(node.getAttribute(attr));
|
||||
if (textTemplate) {
|
||||
bindAttr.push({
|
||||
const bindLogic = {
|
||||
attr: attr,
|
||||
template: textTemplate,
|
||||
});
|
||||
};
|
||||
if (node.nodeName === `SELECT` && attr === `data-e6d-value`) {
|
||||
bindLogic.func = (el, val) => {
|
||||
el.value = val;
|
||||
};
|
||||
}
|
||||
bindAttr.push(bindLogic);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -160,7 +166,12 @@ class TemplateE6d extends HTMLTemplateElement {
|
||||
const injectTarget = resolve(templated, route.route);
|
||||
for (const attr of route.bind.attr) {
|
||||
const attrValue = templateString(attr.template, obj);
|
||||
injectTarget.setAttribute(attr.attr, attrValue);
|
||||
if (attr.func) {
|
||||
attr.func(injectTarget, attrValue);
|
||||
injectTarget.removeAttribute(attr.attr);
|
||||
} else if (attr.template) {
|
||||
injectTarget.setAttribute(attr.attr, attrValue);
|
||||
}
|
||||
}
|
||||
for (const evt of route.bind.event) {
|
||||
const trigger = evt.event;
|
||||
|
||||
Reference in New Issue
Block a user