Adding fixes as optimizations for mutli-div updates

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@3185 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
nate 2006-06-27 10:29:35 +00:00
parent a24b5a32d8
commit 5df320bb89

View file

@ -802,18 +802,23 @@ class AjaxHelper extends Helper {
if (env('HTTP_X_UPDATE') != null && count($this->__ajaxBuffer) > 0) { if (env('HTTP_X_UPDATE') != null && count($this->__ajaxBuffer) > 0) {
$data = array(); $data = array();
$divs = explode(' ', env('HTTP_X_UPDATE')); $divs = explode(' ', env('HTTP_X_UPDATE'));
$keys = array_keys($this->__ajaxBuffer);
if (count($divs) == 1 && in_array($divs[0], $keys)) {
@ob_end_clean();
e($this->__ajaxBuffer[$divs[0]]);
} else {
foreach ($this->__ajaxBuffer as $key => $val) { foreach ($this->__ajaxBuffer as $key => $val) {
if (in_array($key, $divs)) { if (in_array($key, $divs)) {
$data[] = $key . ':"' . rawurlencode($val) . '"'; $data[] = $key . ':"' . rawurlencode($val) . '"';
} }
} }
$out = 'var __ajaxUpdater__ = {' . join(', ', $data) . '};' . "\n"; $out = 'var __ajaxUpdater__ = {' . join(', ', $data) . '};' . "\n";
$out .= 'for (n in __ajaxUpdater__) { if (typeof __ajaxUpdater__[n] == "string" && $(n)) Element.update($(n), unescape(__ajaxUpdater__[n])); }'; $out .= 'for (n in __ajaxUpdater__) { if (typeof __ajaxUpdater__[n] == "string" && $(n)) Element.update($(n), unescape(__ajaxUpdater__[n])); }';
@ob_end_clean(); @ob_end_clean();
e($this->Javascript->codeBlock($out)); e($this->Javascript->codeBlock($out));
}
exit(); exit();
} }
} }