Skip to content

Commit

Permalink
Fixing issues where chained jQuery engine requests wouldn't eval() sc…
Browse files Browse the repository at this point in the history
…ript elements, making ajax pagination much harder.
  • Loading branch information
markstory committed Jan 6, 2010
1 parent 32113a4 commit be7ce6e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions cake/libs/view/helpers/jquery_engine.php
Expand Up @@ -245,6 +245,7 @@ function request($url, $options = array()) {
} else {
$success = 'function (data, textStatus) {$("' . $options['update'] . '").html(data);}';
}
$options['dataType'] = 'html';
$options['success'] = $success;
unset($options['update']);
}
Expand Down
6 changes: 3 additions & 3 deletions cake/tests/cases/libs/view/helpers/jquery_engine.test.php
Expand Up @@ -162,7 +162,7 @@ function testRequest() {
$result = $this->Jquery->request(array('controller' => 'posts', 'action' => 'view', 1), array(
'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);

$result = $this->Jquery->request('/people/edit/1', array(
Expand All @@ -184,7 +184,7 @@ function testRequest() {
'method' => 'post',
'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);

$result = $this->Jquery->request('/people/edit/1', array(
Expand All @@ -195,7 +195,7 @@ function testRequest() {
'data' => '$("#someId").serialize()',
'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);

$result = $this->Jquery->request('/people/edit/1', array(
Expand Down

0 comments on commit be7ce6e

Please sign in to comment.