property inheritance: don't add eventlistener when not needed

This commit is contained in:
jean-emmanuel 2018-01-02 22:09:28 +01:00
parent 49dc77ec65
commit b0d5a8e06b

View file

@ -59,19 +59,27 @@ module.exports = class _widgets_base {
}
}
$('body').on(`widget-created.${this.hash}`, (e)=>{
var {id} = e
if (this.linkedProps[id] && id != this.getProp('id')) {
this.checkPropsChanged(this.linkedProps[id])
}
})
if (Object.keys(this.linkedProps).length) {
$('body').on(`change.${this.hash}`, (e)=>{
var {id} = e
if (this.linkedPropsValue[id] && id != this.getProp('id')) {
this.checkPropsChanged(this.linkedPropsValue[id])
}
})
$('body').on(`widget-created.${this.hash}`, (e)=>{
var {id} = e
if (this.linkedProps[id] && id != this.getProp('id')) {
this.checkPropsChanged(this.linkedProps[id])
}
})
}
if (Object.keys(this.linkedPropsValue).length) {
$('body').on(`change.${this.hash}`, (e)=>{
var {id} = e
if (this.linkedPropsValue[id] && id != this.getProp('id')) {
this.checkPropsChanged(this.linkedPropsValue[id])
}
})
}
$('body').trigger({type: 'widget-created', id: this.getProp('id'), widget:this})