Skip to content
Permalink
Browse files

Updating request() in prototype.

  • Loading branch information...
markstory committed Apr 6, 2009
1 parent 00f3c6f commit f74408df0a54f50ef3a61e0bcb6ddb84f567e88f
@@ -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';
@@ -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

0 comments on commit f74408d

Please sign in to comment.
You can’t perform that action at this time.