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:
12
src/sheet.js
12
src/sheet.js
@ -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 {
|
||||
|
Reference in New Issue
Block a user