From fc88967873fc1825c0495196dee9c924fefb11ee Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Fri, 24 Jan 2020 18:10:53 +0300 Subject: [PATCH] testing a different way to handle callbacks... Signed-off-by: Alex A. Naanou --- ui (gen4)/features/ui-widgets.js | 13 +++++++------ ui (gen4)/lib/widget/widget.js | 2 +- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/ui (gen4)/features/ui-widgets.js b/ui (gen4)/features/ui-widgets.js index 0f575e39..ea30531b 100755 --- a/ui (gen4)/features/ui-widgets.js +++ b/ui (gen4)/features/ui-widgets.js @@ -1252,11 +1252,10 @@ function(spec, callback){ // other... : that(field) }) // batch callback... + var cb callback - // only setup events once... - && !spec.__batch_setup && this.dialog - .close(function(mode){ + .one('close', cb = function(mode){ // XXX get the field data and pass it to the callback... callback( // get the field-value pairs... @@ -1275,9 +1274,11 @@ function(spec, callback){ spec, // XXX is this the right spot for this??? mode) }) - // XXX BUG: if user passes a new spec each time this will not work... - // ...might be a good idea to bind to the element... - spec.__batch_setup = true + // reset the callback on update... + // XXX this does not work yet... + .one('update', function(){ + // XXX BUG: this.off(..) will not work with non-standard events... + this.dom.off('close', cb) }) return this } diff --git a/ui (gen4)/lib/widget/widget.js b/ui (gen4)/lib/widget/widget.js index 329cc630..8676e301 100755 --- a/ui (gen4)/lib/widget/widget.js +++ b/ui (gen4)/lib/widget/widget.js @@ -30,7 +30,7 @@ function(name){ name in this.dom ? // proxy handler... - this.dom[name].apply(this.dom, args) + this.dom[name](...args) // on/trigger handlers... : this.dom.trigger(name, args)