Fixing issues where chained jQuery engine requests wouldn't eval() script elements, making ajax pagination much harder.

This commit is contained in:
Mark Story 2010-01-06 11:59:15 -05:00
parent 32113a4c88
commit be7ce6e923
2 changed files with 4 additions and 3 deletions

View file

@ -245,6 +245,7 @@ class JqueryEngineHelper extends JsBaseEngineHelper {
} else { } else {
$success = 'function (data, textStatus) {$("' . $options['update'] . '").html(data);}'; $success = 'function (data, textStatus) {$("' . $options['update'] . '").html(data);}';
} }
$options['dataType'] = 'html';
$options['success'] = $success; $options['success'] = $success;
unset($options['update']); unset($options['update']);
} }

View file

@ -162,7 +162,7 @@ class JqueryEngineHelperTestCase extends CakeTestCase {
$result = $this->Jquery->request(array('controller' => 'posts', 'action' => 'view', 1), array( $result = $this->Jquery->request(array('controller' => 'posts', 'action' => 'view', 1), array(
'update' => '#content' 'update' => '#content'
)); ));
$expected = '$.ajax({success:function (data, textStatus) {$("#content").html(data);}, url:"\/posts\/view\/1"});'; $expected = '$.ajax({dataType:"html", success:function (data, textStatus) {$("#content").html(data);}, url:"\/posts\/view\/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(
@ -184,7 +184,7 @@ class JqueryEngineHelperTestCase extends CakeTestCase {
'method' => 'post', 'method' => 'post',
'wrapCallbacks' => false 'wrapCallbacks' => false
)); ));
$expected = '$.ajax({success:function (data, textStatus) {$("#updated").html(data);}, type:"post", url:"\\/people\\/edit\\/1"});'; $expected = '$.ajax({dataType:"html", success:function (data, textStatus) {$("#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(), success:function (data, textStatus) {$("#updated").html(data);}, type:"post", url:"\\/people\\/edit\\/1"});'; $expected = '$.ajax({data:$("#someId").serialize(), dataType:"html", success:function (data, textStatus) {$("#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(