Fixing jquery::request() and update key.

Adding drag and drop test skeleton to mootools/jquery
This commit is contained in:
mark_story 2009-03-29 23:00:39 -04:00
parent 23423f2791
commit 87c5a5da6a
3 changed files with 46 additions and 0 deletions

View file

@ -131,6 +131,8 @@ class JqueryEngineHelper extends JsBaseEngineHelper {
/**
* 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 @@ class JqueryEngineHelper extends JsBaseEngineHelper {
$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 .'});';

View file

@ -153,6 +153,14 @@ class JqueryEngineHelperTestCase extends CakeTestCase {
));
$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 @@ class JqueryEngineHelperTestCase extends CakeTestCase {
$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() {
}
}
?>

View file

@ -203,5 +203,21 @@ class MooEngineHelperTestCase extends CakeTestCase {
$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() {
}
}
?>