I follow your logic, I have 2 divs one for the static user content and
another div for the form so you are correct with both being in the source. I
click edit and the user content hides / toggles whatever and the form is now
visible. Click save and I want 2 things to happen.

1. If it saves toggle / remove form and show the updated div again (user
content)

2 If user click save but there are errors nothing gets toggled, the server
sends back the form with the errors and the user content remains hidden
until the form is valid and saved, then the toggleling / effects or whatever
jazzy stuff happens.

I will give it another try and see what happens. Seems simple enough...maybe
just making it more complicated than I have to.

Thanks,

Dave 

-----Original Message-----
From: Miles J [mailto:[email protected]] 
Sent: December-07-09 3:41 PM
To: CakePHP
Subject: Re: Help With Ajax response - Ajax Handler component

If your doing an inline AJAX editing type setup, then the two divs (text and
edit form) should both be present in the source HTML to begin with. All the
JSON object should do is return a success or failure, and then all you do is
display one and hide the other, not return the HTML form again, it should be
present already.

On Dec 7, 10:15 am, "Dave" <[email protected]> wrote:
> Sorry for being a dumb ass, but how would I go about that? I see in 
> your component examples (true, $this->data ) but how would I return 
> the view as the html object?
>
> Thanks again,
>
> Dave
>
> -----Original Message-----
> From: Miles J [mailto:[email protected]]
> Sent: December-07-09 2:29 PM
> To: CakePHP
> Subject: Re: Help With Ajax response - Ajax Handler component
>
> Well then you need to return a JSON object, and set the HTML to be the 
> content of the JSON object.
>
> On Dec 6, 3:17 pm, "Dave" <[email protected]> wrote:
> > I need to keep the if statement. Problem is , will try to explain so 
> > it makes sense.
>
> > I have 2 <div> one for the current user data displayed, click edit 
> > and that <div id="user_content"> toggles away and the <div 
> > is="user_form"> toggles in giving a sliding overlapping effect. The 
> > user clicks save and the <div is="user_form"> toggles out hiding the 
> > form and the  <div id="user_content"> toggles back in showing the 
> > updated content. But if the user attempts to save the data that’s 
> > not valid I do not want the toggling of anything to happen so I 
> > wanted the "if success then do this" if not just return the form 
> > with the errors for correcting. Is there
> an easy way to set this up?
> > (without client side validation)
>
> > Thanks,
>
> > Dave
>
> > -----Original Message-----
> > From: Miles J [mailto:[email protected]]
> > Sent: December-06-09 6:48 PM
> > To: CakePHP
> > Subject: Re: Help With Ajax response - Ajax Handler component
>
> > Well response.success will never work because your not passing a 
> > JSON object. Just remove the if statement in the JS.
>
> > When your responding as html, no object is sent back, just the html
> itself.
>
> > On Dec 6, 1:31 pm, "Dave" <[email protected]> wrote:
> > > I am trying to edit a form using Ajax. I have the submit, save or 
> > > error all working. Just the response I am having problems with. I 
> > > am trying to use Miles Ajax Handler component and basically from 
> > > the
> > controller i need to :
>
> > > if form saves return a success response and the Ajax view with the 
> > > updated content. If it does not save return a fail response and 
> > > show the errors on the form. I know i could use Ajax to validate 
> > > but that's more of a headache and for what i need it for i really 
> > > don't care about user side validation, the form coming back 
> > > showing errors will work
> > just fine.
>
> > > I Need the fail or success response to pass to the JavaScript 
> > > because fail and success  will have 2 different functions so i 
> > > need to know what comes back and how the site should respond
accordingly.
>
> > > script:
> > > $(this).ajaxSubmit({
> > >   type:    'post',
> > >   url:      form_url,
> > >   data:      queryString,
> > >   success: function () {
>
> > >    // Response was a success
> > >    if (response.success == true)
> > >    {
> > >     //do my stuff here for success
>
> > >    // Response contains errors
> > >    } else {
>
> > >     do my stuff here for fail
> > >    }
> > >   }
> > >  });
>
> > > Controller snip of the save part:
> > > if (!empty($this->data)) {
> > >                   $this->Experience->id = $id;
> > >                   if ($this->Experience->save($this->data, true)) 
> > > {
> > >                       $this->set('experience', 
> > > $this->Experience->getExperienceInfo($experience['Experience']['id
> > > ']
> > > ,
> > > $this->Auth->user('id')));
> > >                                   $this->layout = 'ajax';
>
> > > $this->render('/elements/experiences/ajax_edited_block');
> > >                                  
> > > $this->AjaxHandler->response(true);
> > >                                  
> > > $this->AjaxHandler->respond('html');
>
> > >                   } else {
> > >                                  
> > > $this->AjaxHandler->response(false);
> > >                                  
> > > $this->AjaxHandler->respond('html');
> > >                   }
> > >               }
>
> > > Do anyone have any ideas how I can return success = true and the 
> > > html response or success is false and return the form with the 
> > > errors so that the javascript can carry on?
>
> > > Thaks
>
> > > Dave
>
> > Check out the new CakePHP Questions sitehttp://cakeqs.organdhelp 
> > others with their CakePHP related questions.
>
> > You received this message because you are subscribed to the Google 
> > Groups "CakePHP" group.
> > To post to this group, send email to [email protected] To 
> > unsubscribe from this group, send email to
> > [email protected] For more options, visit this 
> > cake-php+group athttp://groups.google.com/group/cake-php?hl=en
> > No virus found in this incoming message.
> > Checked by AVG -www.avg.com
> > Version: 9.0.709 / Virus Database: 270.14.94/2545 - Release Date:
> > 12/06/09 16:07:00
>
> Check out the new CakePHP Questions sitehttp://cakeqs.organd help 
> others with their CakePHP related questions.
>
> You received this message because you are subscribed to the Google 
> Groups "CakePHP" group.
> To post to this group, send email to [email protected] To 
> unsubscribe from this group, send email to
> [email protected] For more options, visit this 
> cake-php+group athttp://groups.google.com/group/cake-php?hl=en
> No virus found in this incoming message.
> Checked by AVG -www.avg.com
> Version: 9.0.709 / Virus Database: 270.14.96/2549 - Release Date: 
> 12/07/09 04:03:00

Check out the new CakePHP Questions site http://cakeqs.org and help others
with their CakePHP related questions.

You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to [email protected] To
unsubscribe from this group, send email to
[email protected] For more options, visit this group 
cake-php+at http://groups.google.com/group/cake-php?hl=en
No virus found in this incoming message.
Checked by AVG - www.avg.com
Version: 9.0.709 / Virus Database: 270.14.96/2549 - Release Date: 12/07/09
04:03:00

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected] For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en

Reply via email to