egw_json plugin "html" replacing document content with send html

This commit is contained in:
Ralf Becker 2012-03-06 09:50:43 +00:00
parent 130dc87e83
commit 4a88a9558c
2 changed files with 20 additions and 1 deletions

View File

@ -248,7 +248,7 @@ class egw_json_response
if (!$inst->haveJSONResponse()) if (!$inst->haveJSONResponse())
{ {
error_log(__METHOD__."() adding output with inst->addGeneric('output', '$output')"); error_log(__METHOD__."() adding output with inst->addGeneric('output', '$output')");
$inst->addGeneric('output', $output); $inst->addGeneric('html', $output);
} }
else else
{ {

View File

@ -360,6 +360,25 @@ egw.extend('json', egw.MODULE_WND_LOCAL, function(_egw, _wnd) {
throw 'Invalid parameters'; throw 'Invalid parameters';
}, null, 'js'); }, null, 'js');
// Register the 'html' plugin, replacing document content with send html
json.registerJSONPlugin(function(type, res, req) {
if (typeof res.data == 'string')
{
// Empty the document tree
while (_wnd.document.childNodes.length > 0)
{
_wnd.document.removeChild(document.childNodes[0]);
}
// Write the given content
_wnd.document.write(res.data);
// Close the document
_wnd.document.close();
}
throw 'Invalid parameters';
}, null, 'html');
// Return the extension // Return the extension
return json; return json;
}); });