From 5df320bb897c3fe59ff167e08cd085b56ece6122 Mon Sep 17 00:00:00 2001 From: nate Date: Tue, 27 Jun 2006 10:29:35 +0000 Subject: [PATCH] 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 --- cake/libs/view/helpers/ajax.php | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/cake/libs/view/helpers/ajax.php b/cake/libs/view/helpers/ajax.php index 3e1fbb7e6..803017e84 100644 --- a/cake/libs/view/helpers/ajax.php +++ b/cake/libs/view/helpers/ajax.php @@ -802,18 +802,23 @@ class AjaxHelper extends Helper { if (env('HTTP_X_UPDATE') != null && count($this->__ajaxBuffer) > 0) { $data = array(); $divs = explode(' ', env('HTTP_X_UPDATE')); + $keys = array_keys($this->__ajaxBuffer); - foreach ($this->__ajaxBuffer as $key => $val) { - if (in_array($key, $divs)) { - $data[] = $key . ':"' . rawurlencode($val) . '"'; + if (count($divs) == 1 && in_array($divs[0], $keys)) { + @ob_end_clean(); + e($this->__ajaxBuffer[$divs[0]]); + } else { + foreach ($this->__ajaxBuffer as $key => $val) { + if (in_array($key, $divs)) { + $data[] = $key . ':"' . rawurlencode($val) . '"'; + } } + $out = 'var __ajaxUpdater__ = {' . join(', ', $data) . '};' . "\n"; + $out .= 'for (n in __ajaxUpdater__) { if (typeof __ajaxUpdater__[n] == "string" && $(n)) Element.update($(n), unescape(__ajaxUpdater__[n])); }'; + + @ob_end_clean(); + e($this->Javascript->codeBlock($out)); } - - $out = 'var __ajaxUpdater__ = {' . join(', ', $data) . '};' . "\n"; - $out .= 'for (n in __ajaxUpdater__) { if (typeof __ajaxUpdater__[n] == "string" && $(n)) Element.update($(n), unescape(__ajaxUpdater__[n])); }'; - - @ob_end_clean(); - e($this->Javascript->codeBlock($out)); exit(); } }