mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
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:
parent
a24b5a32d8
commit
5df320bb89
1 changed files with 14 additions and 9 deletions
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue