Added events to templates so that we can use properties or functions and have them setup on the constructed element for us.

This commit is contained in:
2020-07-30 08:32:44 -07:00
parent 8b98026a5a
commit 68d301c16e
2 changed files with 67 additions and 2 deletions

View File

@ -11,7 +11,8 @@ class Sheet extends IgniteElement {
show: false,
items: ["1", "2"],
href: "www.google.com",
name: "default content"
name: "default content",
linkClick: this.onClick
};
}
@ -27,10 +28,17 @@ class Sheet extends IgniteElement {
new html("<h2>this is after</h2>"),
new html("<h3>---- begin sheet's slot ----<h3>"),
new slot(this),
new html("<h3>---- end of slot ----</h3>")
new html("<h3>---- end of slot ----</h3>"),
new a("I go nowhere, but you can click me ;)").on("click", this.linkClick)
)
);
}
onClick(event) {
console.log("Element was clicked!");
console.log("Event:");
console.log(event);
}
}
class SheetTemplate extends IgniteTemplate {