plots/switchers: bind global sync handlers to the widgets instances and unbind them using the unique hash as reference
This commit is contained in:
parent
62010b7c1b
commit
7ff5ae801f
2 changed files with 21 additions and 19 deletions
|
|
@ -30,19 +30,20 @@ module.exports = class _plots_base extends _canvas_base {
|
|||
}
|
||||
|
||||
|
||||
this.syncHandleProxy = ()=>{
|
||||
|
||||
this.syncHandle(...arguments)
|
||||
$('body').on(`sync.${this.hash}`,this.syncHandleProxy.bind(this))
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
$('body').on('sync',this.syncHandleProxy)
|
||||
syncHandleProxy() {
|
||||
|
||||
this.syncHandle(...arguments)
|
||||
|
||||
}
|
||||
|
||||
onRemove() {
|
||||
|
||||
$('body').off('sync',this.syncHandleProxy)
|
||||
$('body').off(`sync.${this.hash}`)
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -20,26 +20,27 @@ module.exports = class _switchers_base extends _widgets_base {
|
|||
|
||||
}
|
||||
|
||||
this.syncHandler = (e)=>{
|
||||
|
||||
var {id, widget, linkId, fromExternal, options} = e
|
||||
|
||||
if (this.value._selected !== false && this.value[this.value._selected] && widget.abstract._isSwitcher !== true && this.isWatching(id, widget)) {
|
||||
|
||||
this.value[this.value._selected][id] = JSON.parse(JSON.stringify(widget.abstract.getValue()))
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$('body').on('sync',this.syncHandler)
|
||||
$('body').on(`sync.${this.hash}`,this.syncHandler.bind(this))
|
||||
|
||||
|
||||
}
|
||||
|
||||
syncHandler(e) {
|
||||
|
||||
var {id, widget} = e
|
||||
|
||||
if (this.value._selected !== false && this.value[this.value._selected] && widget.abstract._isSwitcher !== true && this.isWatching(id, widget)) {
|
||||
|
||||
this.value[this.value._selected][id] = JSON.parse(JSON.stringify(widget.abstract.getValue()))
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
onRemove() {
|
||||
|
||||
$('body').off('sync',this.syncHandler)
|
||||
$('body').off(`sync.${this.hash}`)
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue