Permalink
Browse files

Updating PrototypeEngineHelper::request() to use dataExpression. Allo…

…wing Js::submit() to work with prototype.
  • Loading branch information...
1 parent dda6c93 commit d4d9db43a712a395e58881701164a4628fe92cf2 @markstory markstory committed Jul 25, 2009
@@ -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 . '}';
@@ -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

0 comments on commit d4d9db4

Please sign in to comment.