From de0c4e850006925a5b965eb0df220dc712625a3a Mon Sep 17 00:00:00 2001 From: nate Date: Sun, 23 Jul 2006 16:10:35 +0000 Subject: [PATCH] Implementing Form.Element.EventObserver in AjaxHelper::observeField (Ticket #1194) git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@3294 3807eeeb-6ff5-0310-8944-8be069107fe0 --- cake/libs/view/helpers/ajax.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/cake/libs/view/helpers/ajax.php b/cake/libs/view/helpers/ajax.php index d93c7b309..b2b7f0c9d 100644 --- a/cake/libs/view/helpers/ajax.php +++ b/cake/libs/view/helpers/ajax.php @@ -398,7 +398,12 @@ class AjaxHelper extends Helper { if (!isset($options['with'])) { $options['with'] = "Form.Element.serialize('$field_id')"; } - return $this->Javascript->codeBlock($this->_buildObserver('Form.Element.Observer', $field_id, $options)); + if (!isset($options['frequency']) || intval($options['frequency']) == 0) { + $observer = 'Event'; + } else { + $observer = ''; + } + return $this->Javascript->codeBlock($this->_buildObserver('Form.Element.' . $observer . 'Observer', $field_id, $options)); } /** @@ -754,7 +759,7 @@ class AjaxHelper extends Helper { $callback = $this->remoteFunction($options); $javascript = "new $klass('$name', "; - $javascript .= (isset($options['frequency']) ? $options['frequency'] : 2) . ", function(element, value) {"; + $javascript .= (isset($options['frequency']) ? $options['frequency'] . ', ' : '') . "function(element, value) {"; $javascript .= "$callback})"; return $javascript; }