mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 17:16:18 +00:00
Fixing jquery::request() and update key.
Adding drag and drop test skeleton to mootools/jquery
This commit is contained in:
parent
23423f2791
commit
87c5a5da6a
3 changed files with 46 additions and 0 deletions
|
@ -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 .'});';
|
||||
|
|
|
@ -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() {
|
||||
|
||||
}
|
||||
}
|
||||
?>
|
|
@ -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() {
|
||||
|
||||
}
|
||||
}
|
||||
?>
|
Loading…
Add table
Reference in a new issue