mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
fix tricky issue with sub widgets modifying el
This commit is contained in:
@@ -6,12 +6,13 @@ import { Counter } from "./counter";
|
||||
const template = `
|
||||
<div class="o_discuss">
|
||||
<span>DISCUSS!!</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>
|
||||
<button t-on-click="resetCounter">Reset first counter</button>
|
||||
<button t-on-click="resetCounterAsync">Reset counter 2 in 3s</button>
|
||||
<button t-on-click="toggle">Toggle Clock/counters</button>
|
||||
<input/>
|
||||
<t t-if="state.validcounter">
|
||||
<t t-widget="Counter" t-ref="counter" t-props="{initialState:4}"/>
|
||||
<t t-widget="Counter" t-ref="counter2" t-props="{initialState:400}"/>
|
||||
</t>
|
||||
<t t-else="1">
|
||||
<t t-widget="Clock"/>
|
||||
@@ -35,15 +36,13 @@ export class Discuss extends Widget<Env> {
|
||||
|
||||
resetCounterAsync(ev: MouseEvent) {
|
||||
setTimeout(() => {
|
||||
if (this.refs.counter instanceof Counter) {
|
||||
this.refs.counter.updateState({ counter: 3 });
|
||||
if (this.refs.counter2 instanceof Counter) {
|
||||
this.refs.counter2.updateState({ counter: 300 });
|
||||
}
|
||||
}, 3000);
|
||||
}
|
||||
|
||||
toggle() {
|
||||
if (this.refs.counter instanceof Counter) {
|
||||
this.updateState({ validcounter: !this.state.validcounter });
|
||||
}
|
||||
this.updateState({ validcounter: !this.state.validcounter });
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user