mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-19 11:06:15 +00:00
Applying patch from 'hashmich' to make jQueryEngine not override the success callback. This allows you to provide a success callback and still get the html insertion when used with the update key.
Tests updated. Fixes #1158
This commit is contained in:
parent
5e26d282a1
commit
5c27abd35f
2 changed files with 10 additions and 11 deletions
|
@ -256,14 +256,13 @@ class JqueryEngineHelper extends JsBaseEngineHelper {
|
||||||
$options['url'] = $url;
|
$options['url'] = $url;
|
||||||
if (isset($options['update'])) {
|
if (isset($options['update'])) {
|
||||||
$wrapCallbacks = isset($options['wrapCallbacks']) ? $options['wrapCallbacks'] : true;
|
$wrapCallbacks = isset($options['wrapCallbacks']) ? $options['wrapCallbacks'] : true;
|
||||||
if ($wrapCallbacks) {
|
$success = '';
|
||||||
$success = $this->jQueryObject . '("' . $options['update'] . '").html(data);';
|
if(isset($options['success']) AND !empty($options['success'])) {
|
||||||
} else {
|
$success .= $options['success'];
|
||||||
$success = sprintf(
|
}
|
||||||
'function (data, textStatus) {%s("%s").html(data);}',
|
$success .= $this->jQueryObject . '("' . $options['update'] . '").html(data);';
|
||||||
$this->jQueryObject,
|
if (!$wrapCallbacks) {
|
||||||
$options['update']
|
$success = 'function (data, textStatus) {' . $success . '}';
|
||||||
);
|
|
||||||
}
|
}
|
||||||
$options['dataType'] = 'html';
|
$options['dataType'] = 'html';
|
||||||
$options['success'] = $success;
|
$options['success'] = $success;
|
||||||
|
|
|
@ -184,7 +184,7 @@ class JqueryEngineHelperTestCase extends CakeTestCase {
|
||||||
'method' => 'post',
|
'method' => 'post',
|
||||||
'wrapCallbacks' => false
|
'wrapCallbacks' => false
|
||||||
));
|
));
|
||||||
$expected = '$.ajax({dataType:"html", success:function (data, textStatus) {$("#updated").html(data);}, type:"post", url:"\\/people\\/edit\\/1"});';
|
$expected = '$.ajax({dataType:"html", success:function (data, textStatus) {doFoo$("#updated").html(data);}, type:"post", url:"\\/people\\/edit\\/1"});';
|
||||||
$this->assertEqual($result, $expected);
|
$this->assertEqual($result, $expected);
|
||||||
|
|
||||||
$result = $this->Jquery->request('/people/edit/1', array(
|
$result = $this->Jquery->request('/people/edit/1', array(
|
||||||
|
@ -195,7 +195,7 @@ class JqueryEngineHelperTestCase extends CakeTestCase {
|
||||||
'data' => '$("#someId").serialize()',
|
'data' => '$("#someId").serialize()',
|
||||||
'wrapCallbacks' => false
|
'wrapCallbacks' => false
|
||||||
));
|
));
|
||||||
$expected = '$.ajax({data:$("#someId").serialize(), dataType:"html", success:function (data, textStatus) {$("#updated").html(data);}, type:"post", url:"\\/people\\/edit\\/1"});';
|
$expected = '$.ajax({data:$("#someId").serialize(), dataType:"html", success:function (data, textStatus) {doFoo$("#updated").html(data);}, type:"post", url:"\\/people\\/edit\\/1"});';
|
||||||
$this->assertEqual($result, $expected);
|
$this->assertEqual($result, $expected);
|
||||||
|
|
||||||
$result = $this->Jquery->request('/people/edit/1', array(
|
$result = $this->Jquery->request('/people/edit/1', array(
|
||||||
|
@ -225,7 +225,7 @@ class JqueryEngineHelperTestCase extends CakeTestCase {
|
||||||
'data' => '$j("#someId").serialize()',
|
'data' => '$j("#someId").serialize()',
|
||||||
'wrapCallbacks' => false
|
'wrapCallbacks' => false
|
||||||
));
|
));
|
||||||
$expected = '$j.ajax({data:$j("#someId").serialize(), dataType:"html", success:function (data, textStatus) {$j("#updated").html(data);}, type:"post", url:"\\/people\\/edit\\/1"});';
|
$expected = '$j.ajax({data:$j("#someId").serialize(), dataType:"html", success:function (data, textStatus) {doFoo$j("#updated").html(data);}, type:"post", url:"\\/people\\/edit\\/1"});';
|
||||||
$this->assertEqual($result, $expected);
|
$this->assertEqual($result, $expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue