Commit 50f295f3 authored by Jonny Bradley's avatar Jonny Bradley

[FIX] services: Add js files added to the output to the AJAX return, and only...

[FIX] services: Add js files added to the output to the AJAX return, and only add in the js and files this particular template uses.
Fixes smiley picker causing annoying page reloads in comments.
parent 5fe4035a
......@@ -114,8 +114,21 @@ class Services_Broker
return $smarty->fetch($template);
} elseif ($access->is_xml_http_request()) {
$headerlib = TikiLib::lib('header');
// similar to code in \WikiLib::get_parse, TODO refactor into headerlib for tiki 13
$jsFile1 = $headerlib->getJsfiles();
$js1 = $headerlib->getJs();
$content = $smarty->fetch($template);
$content .= $headerlib->output_js();
// get any JS added to headerlib during $smarty->fetch and add to the output
$jsFile = array_diff($headerlib->getJsfiles(), $jsFile1);
$js = array_diff($headerlib->getJs(), $js1);
if ($jsFile) {
$content .= implode("\n", $jsFile);
}
if ($js) {
$content .= $headerlib->wrap_js(implode("\n", $js));
}
return $content;
} else {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment