Checkbox example
This commit is contained in:
parent
4abe74fbf1
commit
dc0da41fb1
2 changed files with 11 additions and 6 deletions
|
@ -3,15 +3,17 @@ import {UIEventSource} from "../UIEventSource";
|
|||
|
||||
|
||||
export class CheckBox extends UIElement{
|
||||
private data: UIEventSource<boolean>;
|
||||
|
||||
constructor(data: UIEventSource<boolean>) {
|
||||
super(data);
|
||||
this.data = data;
|
||||
|
||||
}
|
||||
|
||||
|
||||
protected InnerRender(): string {
|
||||
return "";
|
||||
return "Current val: "+this.data.data;
|
||||
}
|
||||
|
||||
}
|
13
test.ts
13
test.ts
|
@ -7,11 +7,14 @@ import {OsmLink} from "./Customizations/Questions/OsmLink";
|
|||
import {ConfirmDialog} from "./UI/ConfirmDialog";
|
||||
import {Imgur} from "./Logic/Imgur";
|
||||
import {VariableUiElement} from "./UI/Base/VariableUIElement";
|
||||
import {CheckBox} from "./UI/Base/CheckBox";
|
||||
|
||||
|
||||
const html = new UIEventSource<string>("Some text");
|
||||
const eventSource = new UIEventSource(false);
|
||||
eventSource.addCallback(console.log)
|
||||
|
||||
const uielement = new VariableUiElement(html);
|
||||
uielement.AttachTo("maindiv")
|
||||
|
||||
window.setTimeout(() => {html.setData("Different text")}, 1000)
|
||||
new CheckBox(eventSource)
|
||||
.onClick(() => {
|
||||
eventSource.setData(!eventSource.data);
|
||||
})
|
||||
.AttachTo("maindiv");
|
||||
|
|
Loading…
Reference in a new issue