#2339: ajax->observeField generates incorrect code when frequency < 1 ----------------------------------+----------------------------------------- Reporter: bernardo | Owner: Any Developer Type: Bug | Status: reopened Priority: Low | Milestone: Component: Helpers | Version: RC1 Severity: Minor | Resolution: Keywords: ajax observeField | Php_version: PHP 4 >= 4.3.0 Cake_version: | ----------------------------------+----------------------------------------- Comment (by Dieter_be):
I can confirm this. here is the code to get a working observer that submits when the contents of any of fields of the form have changed (with frequency 1s) {{{ <?php echo $ajax->observeForm("InvoicelineAddForm" . $invoiceline['id'],array('url'=> array ('action' => 'edit_ajax','controller' => 'invoicelines'), 'frequency' => '1', 'indicator' => 'hourglass' . $invoiceline['id'])); ?> //<![CDATA[ new Form.EventObserver('InvoicelineAddForm1', function(element, value) {new Ajax.Request('/colomanager/invoicelines/edit_ajax', {asynchronous:true, evalScripts:true, onComplete:function(request, json) {Element.hide('hourglass1');}, onLoading:function(request) {Element.show('hourglass1');}, parameters:Form.serialize('InvoicelineAddForm1')})}) //]]> }}} With the following code, the frequency is ignored. when you change a field, nothing happens until you actively de-focus the field (eg click somewhere else on the page). Only then the ajax request happens. {{{ <?php echo $ajax->observeForm("InvoicelineAddForm" . $invoiceline['id'],array('url'=> array ('action' => 'edit_ajax','controller' => 'invoicelines'), 'frequency' => '0.2', 'indicator' => 'hourglass' . $invoiceline['id'])); ?> //<![CDATA[ new Form.EventObserver('InvoicelineAddForm1', function(element, value) {new Ajax.Request('/crm-new/invoicelines/edit_ajax', {asynchronous:true, evalScripts:true, onComplete:function(request, json) {Element.hide('hourglass1');}, onLoading:function(request) {Element.show('hourglass1');}, parameters:Form.serialize('InvoicelineAddForm1')})}) //]]> }}} -- Ticket URL: <https://trac.cakephp.org/ticket/2339#comment:3> CakePHP : The Rapid Development Framework for PHP <https://trac.cakephp.org/> Cake is a rapid development framework for PHP which uses commonly known design patterns like ActiveRecord, Association Data Mapping, Front Controller and MVC. Our primary goal is to provide a structured framework that enables PHP users at all levels to rapidly develop robust web applications, without any loss to flexibility. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "tickets cakephp" group. To post to this group, send email to tickets-cakephp@googlegroups.com To unsubscribe from this group, send email to tickets-cakephp+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/tickets-cakephp?hl=en -~----------~----~----~----~------~----~------~--~---