Skip to content

Commit

Permalink
Updating request() in prototype.
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed Apr 6, 2009
1 parent 00f3c6f commit f74408d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 25 deletions.
9 changes: 2 additions & 7 deletions cake/libs/view/helpers/prototype_engine.php
Expand Up @@ -164,14 +164,9 @@ function request($url, $options = array()) {
$options = $this->_mapOptions('request', $options);
$type = '.Request';
$data = null;
/*if (isset($options['type']) && strtolower($options['type']) == 'json') {
$type = '.JSON';
if (!empty($options['data'])) {
$data = $this->object($options['data']);
unset($options['data']);
}
if (isset($options['type']) && strtolower($options['type']) == 'json') {
unset($options['type']);
}*/
}
if (isset($options['update'])) {
$url = '"' . str_replace('#', '', $options['update']) . '", ' . $url;
$type = '.Updater';
Expand Down
20 changes: 2 additions & 18 deletions cake/tests/cases/libs/view/helpers/prototype_engine.test.php
Expand Up @@ -196,32 +196,16 @@ function testRequest() {
$expected = 'var jsRequest = new Ajax.Updater("update-zone", "/people/edit/1", {method:"post", onComplete:doSuccess});';
$this->assertEqual($result, $expected);

/* $result = $this->Proto->request('/people/edit/1', array(
$result = $this->Proto->request('/people/edit/1', array(
'method' => 'post',
'complete' => 'doSuccess',
'error' => 'handleError',
'type' => 'json',
'data' => array('name' => 'jim', 'height' => '185cm')
));
$expected = 'var jsRequest = new Request.JSON({method:"post", onComplete:doSuccess, onFailure:handleError, url:"/people/edit/1"}).send({"name":"jim","height":"185cm"});';
$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',
'update' => '#update-zone'
));
$expected = 'var jsRequest = new Request.HTML({method:"post", onComplete:doSuccess, update:"update-zone", url:"/people/edit/1"}).send();';
$this->assertEqual($result, $expected);
$result = $this->Proto->request('/people/edit/1', array(
'method' => 'post',
'complete' => 'doSuccess',
'update' => 'update-zone'
));
$expected = 'var jsRequest = new Request.HTML({method:"post", onComplete:doSuccess, update:"update-zone", url:"/people/edit/1"}).send();';
$this->assertEqual($result, $expected);
*/
}
/**
* test sortable list generation
Expand Down

0 comments on commit f74408d

Please sign in to comment.