forked from extern/egroupware
Only call request callback once, when the request is finished.
Callback is not called if the response only has 'data' type responses, since data handler calls callback already.
This commit is contained in:
parent
c8cfe6464e
commit
8e69a1e23b
@ -130,10 +130,15 @@ egw.extend('json', egw.MODULE_WND_LOCAL, function(_app, _wnd) {
|
||||
}, this);
|
||||
return;
|
||||
}
|
||||
|
||||
// Flag for only data response - don't call callback if only data
|
||||
var only_data = true;
|
||||
|
||||
for (var i = 0; i < data.response.length; i++)
|
||||
{
|
||||
// Get the response object
|
||||
var res = data.response[i];
|
||||
if(typeof res.type == 'string' && res.type != 'data') only_data = false;
|
||||
|
||||
// Check whether a plugin for the given type exists
|
||||
if (typeof plugins[res.type] !== 'undefined')
|
||||
@ -148,14 +153,6 @@ egw.extend('json', egw.MODULE_WND_LOCAL, function(_app, _wnd) {
|
||||
plugin.context ? plugin.context : this.context,
|
||||
res.type, res, this
|
||||
);
|
||||
|
||||
// Call request callback, if provided
|
||||
// Data is special, don't do the callback for it
|
||||
if(this.callback != null && res.type != "data")
|
||||
{
|
||||
this.callback.call(this.context,res);
|
||||
}
|
||||
|
||||
} catch(e) {
|
||||
var msg = e.message ? e.message : e + '';
|
||||
var stack = e.stack ? "\n-- Stack trace --\n" + e.stack : ""
|
||||
@ -164,6 +161,11 @@ egw.extend('json', egw.MODULE_WND_LOCAL, function(_app, _wnd) {
|
||||
}
|
||||
}
|
||||
}
|
||||
// Call request callback, if provided
|
||||
if(this.callback != null && !only_data)
|
||||
{
|
||||
this.callback.call(this.context,res);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -44,6 +44,9 @@ egw.extend('jsonq', egw.MODULE_GLOBAL, function() {
|
||||
function jsonq_callback(_data)
|
||||
{
|
||||
if (typeof _data != 'object') throw "jsonq_callback called with NO object as parameter!";
|
||||
|
||||
// Abort if type is set (multi-response support)
|
||||
if (typeof _data.type != 'undefined') return;
|
||||
|
||||
var json = egw.json('none');
|
||||
for(var uid in _data)
|
||||
|
Loading…
Reference in New Issue
Block a user