Permalink
Browse files

Updating request in Mootools

  • Loading branch information...
1 parent a899af6 commit 23423f27911dc0062faf2a4cd355720b8fb9a983 @markstory markstory committed Mar 30, 2009
@@ -570,9 +570,9 @@ function effect($name, $options) {
* - 'method' - The method to make the request with defaults to GET in more libraries
* - 'async' - Whether or not you want an asynchronous request.
* - 'data' - Additional data to send.
- * - 'update' - Dom selector to update with the content of the request.
+ * - 'update' - Dom id to update with the content of the request.
* - 'type' - Data type for response. 'json' and 'html' are supported. Default is html for most libraries.
- * - 'evalScripts' - Whether or not <script> tags should be evaled.
+ * - 'evalScripts' - Whether or not <script> tags should be eval'ed.
*
* @param mixed $url Array or String URL to target with the request.
* @param array $options Array of options. See above for cross library supported options
@@ -176,6 +176,7 @@ function request($url, $options = array()) {
unset($options['type']);
}
if (isset($options['update'])) {
+ $options['update'] = str_replace('#', '', $options['update']);
$type = '.HTML';
if (!empty($options['data'])) {
$data = $this->_toQuerystring($options['data']);
@@ -170,6 +170,22 @@ function testRequest() {
));
$expected = 'var jsRequest = new Request.JSON({method:"post", onComplete:doSuccess, onFailure:handleError, url:"/people/edit/1"}).send({"name":"jim","height":"185cm"});';
$this->assertEqual($result, $expected);
+
+ $result = $this->Moo->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->Moo->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 23423f2

Please sign in to comment.