Hey guys, One more question about the dojo forms. I've noticed that when I use the form I created in Firefox, hitting enter while in a text box or something does not process the form, whereas in Safari it does. However, it doesn't use my xhrPost routine (obviously because it's not bound to it)
is there a reason why this might be browser dependent? and.. is there a way to bind the "enter" key to my xhrPost routine? thanks! mapes911 wrote: > > Thanks a lot Mark!! > This helped me a ton and I got my form to work for the most part :) > > > > MarkDNA wrote: >> >> >> mapes911 wrote: >>> >>> Hi Matthew, >>> >>> If you use this method to attach the javascript routine to the submit >>> button, then in the foobar routine setup an xhrPost to process the form, >>> should I still have an action and a method setup in my controller when I >>> instantiate my form? >>> >>> Any help would be appreciated. >>> >>> Thanks >>> >> >> I'm doing this exact thing, so let me see if giving an example would help >> your understanding. Sorry if this is a bit long folks. I've used ellipses >> to try and make it shorter. >> >> Controller File: (clients/controllers/IndexController.php) >> >> public function getContactEditForm($clientContactID = null){ >> ... >> $contactForm = new Zend_Dojo_Form(); >> ... >> $elements[] = $contactForm->createElement('button', 'ajaxActionContact', >> array( >> 'onclick' => "ajaxAdd('clientContacts','clientContactForm')", >> 'label' => 'Add Client Contact')); >> $contactForm->addElements($elements); >> return $contactForm; >> } >> >> public function editAction(){ >> ... >> [I've already set $this->view->info["contacts"]] >> $contactForm = $this->getContactEditForm(); >> $this->view->contactForm = $contactForm; >> } >> >> public function editajaxAction(){ >> ... >> [Do what logic is needed (add in this case), pull back new list of >> contacts] >> ... >> $this->view->contactList = $contactList; >> $this->_helper->layout->disableLayout(); >> $this->render('editClientContactPartial'); break; >> } >> >> >> View File:(clients/views/scripts/index/edit.phtml) >> >> <? $this->dojo()->javascriptCaptureStart() ?> >> var ajaxAdd = function(divID, formName) { >> var kw = { >> url: "<?=BASEURL."clients/index/editajax"?>", >> handleAs:"text", >> load: function(response){ >> dojo.byId(divID).innerHTML = response; >> }, >> error: function(data){ >> alert("An error occurred: " + data); >> }, >> timeout: 2000, >> form: formName >> }; >> dojo.xhrPost(kw); //Servlet get argement with doPost >> } >> >> <? $this->dojo()->javascriptCaptureEnd() ?> >> >> ... >> >> <div id="clientContacts"> >> <?=$this->partial('index/edit-client-contact-partial.phtml', >> array("contactList" =>$this->info["contacts"]))?> >> </div> >> >> >> So what we have here is a controller file with several actions. Included >> are ones to create the Dojo form (getContactEditForm), the edit action >> that fires when we first get to the page (editAction), and what I want to >> happen when the form is submitted via the XHR call (editajaxAction). >> >> When the page is first called, the form is created with a button that has >> an onclick action pointing to a simple js function that captures the form >> info and posts it to the editajaxAction function. The response is then >> loaded into the clientContacts div. Of note here, if you are using >> layouts and are updating a partial (like I am doing), you will need to >> disable layout rending in your ajax action, or the entire layout will >> render inside the partial! ($this->_helper->layout->disableLayout();) >> >> -Mark G. >> >> >> > > -- View this message in context: http://www.nabble.com/Zend_Dojo_Form---XHR-Post-tp19360770p22548594.html Sent from the Zend Framework mailing list archive at Nabble.com.