diff --git a/cake/libs/view/helpers/jquery_engine.php b/cake/libs/view/helpers/jquery_engine.php index 0d66561e3..c16c08745 100644 --- a/cake/libs/view/helpers/jquery_engine.php +++ b/cake/libs/view/helpers/jquery_engine.php @@ -178,15 +178,19 @@ class JqueryEngineHelper extends JsBaseEngineHelper { } /** - * Create a domReady event. For jQuery + * Create a domReady event. For jQuery. This method does not + * bind a 'traditional event' as `$(document).bind('ready', fn)` + * Works in an entirely different fashion than `$(document).ready()` + * The first will not run the function when eval()'d as part of a response + * The second will. Because of the way that ajax pagination is done + * `$().ready()` is used. * * @param string $functionBody The code to run on domReady * @return string completed domReady method * @access public */ function domReady($functionBody) { - $this->get('document'); - return $this->event('ready', $functionBody, array('stop' => false)); + return $this->jQueryObject . '(document).ready(function () {' . $functionBody . '});'; } /** diff --git a/cake/tests/cases/libs/view/helpers/jquery_engine.test.php b/cake/tests/cases/libs/view/helpers/jquery_engine.test.php index dd9665482..1a2ba66c6 100644 --- a/cake/tests/cases/libs/view/helpers/jquery_engine.test.php +++ b/cake/tests/cases/libs/view/helpers/jquery_engine.test.php @@ -89,7 +89,7 @@ class JqueryEngineHelperTestCase extends CakeTestCase { */ function testDomReady() { $result = $this->Jquery->domReady('foo.name = "bar";'); - $expected = '$(document).bind("ready", function (event) {foo.name = "bar";});'; + $expected = '$(document).ready(function () {foo.name = "bar";});'; $this->assertEqual($result, $expected); }