Adding 'evalScripts' fix for AjaxHelper (Ticket #2048)

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@4448 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
nate 2007-02-04 19:28:22 +00:00
parent 9f7024d513
commit 8f641887b7

View file

@ -662,32 +662,28 @@ class AjaxHelper extends AppHelper {
unset($options['indicator']); unset($options['indicator']);
} }
$js_options = $this->_buildCallbacks($options); $jsOptions = am(
array('asynchronous' => 'true', 'evalScripts' => 'true'),
if (!isset($js_options['asynchronous'])) { $this->_buildCallbacks($options)
$js_options['asynchronous'] = 'true'; );
}
if (!isset($js_options['evalScripts'])) {
$js_options['evalScripts'] = 'true';
}
$options = $this->_optionsToString($options, array('method')); $options = $this->_optionsToString($options, array('method'));
foreach($options as $key => $value) { foreach($options as $key => $value) {
switch($key) { switch($key) {
case 'type': case 'type':
$js_options['asynchronous'] = ($value == 'synchronous') ? 'false' : 'true'; $jsOptions['asynchronous'] = ife(($value == 'synchronous'), 'false', 'true');
break;
case 'evalScripts':
$jsOptions['evalScripts'] = ife($value, 'true', 'false');
break; break;
case 'position': case 'position':
$js_options['insertion'] = "Insertion." . Inflector::camelize($options['position']); $jsOptions['insertion'] = "Insertion." . Inflector::camelize($options['position']);
break; break;
case 'with': case 'with':
$js_options['parameters'] = $options['with']; $jsOptions['parameters'] = $options['with'];
break; break;
case 'form': case 'form':
$js_options['parameters'] = 'Form.serialize(this)'; $jsOptions['parameters'] = 'Form.serialize(this)';
break; break;
case 'requestHeaders': case 'requestHeaders':
$keys = array(); $keys = array();
@ -695,13 +691,21 @@ class AjaxHelper extends AppHelper {
$keys[] = "'" . $key . "'"; $keys[] = "'" . $key . "'";
$keys[] = "'" . $val . "'"; $keys[] = "'" . $val . "'";
} }
$js_options['requestHeaders'] = '[' . join(', ', $keys) . ']'; $jsOptions['requestHeaders'] = '[' . join(', ', $keys) . ']';
break; break;
} }
} }
return $this->_buildOptions($js_options, $this->ajaxOptions); return $this->_buildOptions($jsOptions, $this->ajaxOptions);
} }
/**
* Private Method to return a string of html options
* option data as a JavaScript options hash.
*
* @param array $options Options in the shape of keys and values
* @param array $extra Array of legal keys in this options context
* @return array Array of html options
* @access private
*/
function __getHtmlOptions($options, $extra = array()) { function __getHtmlOptions($options, $extra = array()) {
foreach($this->ajaxOptions as $key) { foreach($this->ajaxOptions as $key) {
if (isset($options[$key])) { if (isset($options[$key])) {