mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
t-widget directive
This commit is contained in:
@@ -5,6 +5,7 @@ const template = `
|
||||
<div t-debug="1">
|
||||
<span>Root Widget</span>
|
||||
<button t-on-click="resetCounter">Reset</button>
|
||||
<button t-on-click="resetCounterAsync">Reset in 3s</button>
|
||||
<button t-on-click="toggle">Toggle Counter</button>
|
||||
<input/>
|
||||
<t t-if="state.validcounter">
|
||||
@@ -23,6 +24,12 @@ export default class RootWidget extends Widget {
|
||||
this.refs.counter.updateState({counter: 3})
|
||||
}
|
||||
|
||||
resetCounterAsync(ev: MouseEvent) {
|
||||
setTimeout(() => {
|
||||
this.refs.counter.updateState({counter: 3})
|
||||
}, 3000);
|
||||
}
|
||||
|
||||
toggle() {
|
||||
this.updateState({validcounter: !this.state.validcounter});
|
||||
}
|
||||
|
||||
+3
-3
@@ -11,12 +11,12 @@
|
||||
// (<any>window).h = h;
|
||||
// (<any>window).patch = patch;
|
||||
// (<any>window).QWeb = QWeb;
|
||||
import Counter from "./Counter";
|
||||
// import RootWidget from "./RootWidget";
|
||||
// import Counter from "./Counter";
|
||||
import RootWidget from "./RootWidget";
|
||||
import env from "./env";
|
||||
|
||||
document.addEventListener("DOMContentLoaded", async function() {
|
||||
const rootWidget = new Counter(null, {});
|
||||
const rootWidget = new RootWidget(null);
|
||||
rootWidget.setEnvironment(env);
|
||||
const mainDiv = document.getElementById("app")!;
|
||||
await rootWidget.mount(mainDiv);
|
||||
|
||||
Reference in New Issue
Block a user