Permalink
Browse files

Fixing jquery::request() and update key.

Adding drag and drop test skeleton to mootools/jquery
  • Loading branch information...
markstory committed Mar 30, 2009
1 parent 23423f2 commit 87c5a5da6afd369ad44f692bf97e2ad547b093f0
@@ -131,6 +131,8 @@ function effect($name, $options = array()) {
/**
* Create an $.ajax() call.
*
+ * If the 'update' key is set, success callback will be overridden.
+ *
* @param mixed $url
* @param array $options
* @return string The completed ajax call.
@@ -142,6 +144,10 @@ function request($url, $options = array()) {
$options['data'] = $this->_toQuerystring($options['data']);
}
$options['url'] = $url;
+ if (isset($options['update'])) {
+ $options['success'] = 'function (msg, status) {$("' . $options['update'] . '").html(msg);}';
+ unset($options['update']);
+ }
$callbacks = array('success', 'error', 'beforeSend', 'complete');
$options = $this->_parseOptions($options, $callbacks);
return '$.ajax({' . $options .'});';
@@ -153,6 +153,14 @@ function testRequest() {
));
$expected = '$.ajax({data:"name=jim&height=185cm", dataType:"json", error:handleError, method:"post", success:doSuccess, url:"/people/edit/1"});';
$this->assertEqual($result, $expected);
+
+ $result = $this->Jquery->request('/people/edit/1', array(
+ 'update' => '#updated',
+ 'success' => 'doFoo',
+ 'method' => 'post'
+ ));
+ $expected = '$.ajax({method:"post", success:function (msg, status) {$("#updated").html(msg);}, url:"/people/edit/1"});';
+ $this->assertEqual($result, $expected);
}
/**
* test sortable list generation
@@ -170,5 +178,21 @@ function testSortable() {
$expected = '$("#myList").sortable({containment:"parent", distance:5, sort:onSort, start:onStart, stop:onStop});';
$this->assertEqual($result, $expected);
}
+/**
+ * test drag() method
+ *
+ * @return void
+ **/
+ function testDrag() {
+
+ }
+/**
+ * test drop() method
+ *
+ * @return void
+ **/
+ function testDrop() {
+
+ }
}
?>
@@ -203,5 +203,21 @@ function testSortable() {
$expected = 'var mooSortable = new Sortables($("myList"), {constrain:"parent", onComplete:onStop, onSort:onSort, onStart:onStart, snap:5});';
$this->assertEqual($result, $expected);
}
+/**
+ * test drag() method
+ *
+ * @return void
+ **/
+ function testDrag() {
+
+ }
+/**
+ * test drop() method
+ *
+ * @return void
+ **/
+ function testDrop() {
+
+ }
}
?>

0 comments on commit 87c5a5d

Please sign in to comment.