mirror of
https://github.com/esiur/iui.git
synced 2025-05-06 06:42:58 +00:00
Repeat+Event
This commit is contained in:
parent
90e9fb5c71
commit
95884c4f2d
@ -3,6 +3,7 @@ import { Binding, BindingType } from "./Binding.js";
|
|||||||
//import Route from '../Router/Route.js';
|
//import Route from '../Router/Route.js';
|
||||||
import BindingList from "./BindingList.js";
|
import BindingList from "./BindingList.js";
|
||||||
|
|
||||||
|
const AsyncFunction = Object.getPrototypeOf(async function () { }).constructor;
|
||||||
|
|
||||||
export class IUI {
|
export class IUI {
|
||||||
|
|
||||||
@ -228,7 +229,7 @@ export class IUI {
|
|||||||
|
|
||||||
bindings.addEvent(attr.name.substr(1), handler);
|
bindings.addEvent(attr.name.substr(1), handler);
|
||||||
}
|
}
|
||||||
else if (attr.name.startsWith(":::"))
|
else if (attr.name.startsWith("event:"))
|
||||||
{
|
{
|
||||||
// make events
|
// make events
|
||||||
let code = attr.value;
|
let code = attr.value;
|
||||||
@ -238,9 +239,20 @@ export class IUI {
|
|||||||
func.call(element, event, ...scopeValues);
|
func.call(element, event, ...scopeValues);
|
||||||
}
|
}
|
||||||
|
|
||||||
bindings.addEvent(attr.name.substr(3), handler);
|
bindings.addEvent(attr.name.substr(6), handler);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
else if (attr.name.startsWith("async-event:")) {
|
||||||
|
// make events
|
||||||
|
let code = attr.value;
|
||||||
|
//let code = `try {\r\n context.value = ${script}; \r\n}\r\n catch(ex) { context.error = ex; }`
|
||||||
|
let func = new AsyncFunction("event", ...scopeArgs, code);
|
||||||
|
let handler = (event) => {
|
||||||
|
func.call(element, event, ...scopeValues);
|
||||||
|
}
|
||||||
|
|
||||||
|
bindings.addEvent(attr.name.substr(12), handler);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
let b = Binding.create(attr, bindings.scope);
|
let b = Binding.create(attr, bindings.scope);
|
||||||
|
@ -144,12 +144,17 @@ export default IUI.module(class Repeat extends IUIElement
|
|||||||
|
|
||||||
this.list.push(el);
|
this.list.push(el);
|
||||||
|
|
||||||
|
try {
|
||||||
await IUI.create(el);
|
await IUI.create(el);
|
||||||
|
|
||||||
IUI.bind(el, false, "repeat",
|
IUI.bind(el, false, "repeat",
|
||||||
IUI.extend(this.__i_bindings?.scope,
|
IUI.extend(this.__i_bindings?.scope,
|
||||||
{index: i, repeat: this}, true));
|
{index: i, repeat: this}, true));
|
||||||
|
|
||||||
|
} catch (ex) {
|
||||||
|
console.log(ex);
|
||||||
|
}
|
||||||
|
|
||||||
this._container.insertBefore(el, this._beforeNode);
|
this._container.insertBefore(el, this._beforeNode);
|
||||||
|
|
||||||
// update referencing
|
// update referencing
|
||||||
|
Loading…
x
Reference in New Issue
Block a user