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 BindingList from "./BindingList.js";
|
||||
|
||||
const AsyncFunction = Object.getPrototypeOf(async function () { }).constructor;
|
||||
|
||||
export class IUI {
|
||||
|
||||
@ -228,7 +229,7 @@ export class IUI {
|
||||
|
||||
bindings.addEvent(attr.name.substr(1), handler);
|
||||
}
|
||||
else if (attr.name.startsWith(":::"))
|
||||
else if (attr.name.startsWith("event:"))
|
||||
{
|
||||
// make events
|
||||
let code = attr.value;
|
||||
@ -238,9 +239,20 @@ export class IUI {
|
||||
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
|
||||
{
|
||||
let b = Binding.create(attr, bindings.scope);
|
||||
|
@ -144,11 +144,16 @@ export default IUI.module(class Repeat extends IUIElement
|
||||
|
||||
this.list.push(el);
|
||||
|
||||
await IUI.create(el);
|
||||
try {
|
||||
await IUI.create(el);
|
||||
|
||||
IUI.bind(el, false, "repeat",
|
||||
IUI.extend(this.__i_bindings?.scope,
|
||||
{index: i, repeat: this}, true));
|
||||
IUI.bind(el, false, "repeat",
|
||||
IUI.extend(this.__i_bindings?.scope,
|
||||
{index: i, repeat: this}, true));
|
||||
|
||||
} catch (ex) {
|
||||
console.log(ex);
|
||||
}
|
||||
|
||||
this._container.insertBefore(el, this._beforeNode);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user