Skip to content

Commit

Permalink
Updating PrototypeEngineHelper::request() to use dataExpression. Allo…
Browse files Browse the repository at this point in the history
…wing Js::submit() to work with prototype.
  • Loading branch information
markstory committed Jul 25, 2009
1 parent dda6c93 commit d4d9db4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
4 changes: 4 additions & 0 deletions cake/libs/view/helpers/prototype_engine.php
Expand Up @@ -193,6 +193,10 @@ function request($url, $options = array()) {
unset($options['update'], $options['type']);
}
$callbacks = array('onCreate', 'onComplete', 'onFailure', 'onRequest', 'onSuccess');
if (isset($options['dataExpression'])) {
$callbacks[] = 'parameters';
unset($options['dataExpression']);
}
$options = $this->_parseOptions($options, $callbacks);
if (!empty($options)) {
$options = ', {' . $options . '}';
Expand Down
11 changes: 11 additions & 0 deletions cake/tests/cases/libs/view/helpers/prototype_engine.test.php
Expand Up @@ -205,6 +205,17 @@ function testRequest() {
));
$expected = 'var jsRequest = new Ajax.Request("/people/edit/1", {method:"post", onComplete:doSuccess, onFailure:handleError, parameters:{"name":"jim","height":"185cm"}});';
$this->assertEqual($result, $expected);

$result = $this->Proto->request('/people/edit/1', array(
'method' => 'post',
'complete' => 'doSuccess',
'error' => 'handleError',
'type' => 'json',
'data' => '$("element").serialize()',
'dataExpression' => true
));
$expected = 'var jsRequest = new Ajax.Request("/people/edit/1", {method:"post", onComplete:doSuccess, onFailure:handleError, parameters:$("element").serialize()});';
$this->assertEqual($result, $expected);
}
/**
* test sortable list generation
Expand Down

0 comments on commit d4d9db4

Please sign in to comment.