/** * Executed after a view has rendered, used to include bufferred code * blocks. * * @access public */ function afterRender() { if (env('HTTP_X_UPDATE') != null && !empty($this->__ajaxBuffer)) { @ob_end_clean(); $data = array(); $divs = explode(' ', env('HTTP_X_UPDATE')); $keys = array_keys($this->__ajaxBuffer); if (count($divs) == 1 && in_array($divs[0], $keys)) { echo $this->__ajaxBuffer[$divs[0]]; } else { foreach ($this->__ajaxBuffer as $key => $val) { if (in_array($key, $divs)) { $data[] = $key . ':"' . rawurlencode($val) . '"'; } } $out = 'var __ajaxUpdater__ = {' . implode(", \n", $data) . '};' . "\n"; $out .= 'for (n in __ajaxUpdater__) { if (typeof __ajaxUpdater__[n] == "string"'; $out .= ' && $(n)) Element.update($(n), unescape(decodeURIComponent('; $out .= '__ajaxUpdater__[n]))); }'; echo $this->Javascript->codeBlock($out, false); } $scripts = $this->Javascript->getCache(); if (!empty($scripts)) { echo $this->Javascript->codeBlock($scripts, false); } $this->_stop(); } }