Your two options are essentially the same thing. Either way, you're
making a request to the controller. Another option would be to include
the form in the view from the start, but hide it.
Personally, what I usually do is have jquery intercept the edit link
and make an AJAX request instead using the link's href (which passes
the ID of the thing I want to edit).
I make the form itself an element which is included into my add & edit
views with $this->element('form').
So in the controller I set $layout to false and change $viewPath to,
eg. 'elements'.DS.'Products' and then call $this->render('form') to
send it back as the AJAX response.
On Mon, Jun 25, 2012 at 7:15 AM, Florin Trifu
<florin.catalin.trifu@gmail.com> wrote:
> Hi
>
> On my page, I have a table with the information of a company and a
> button to edit the information. On click, through jQuery and AJAX, I
> want to transform that table into a form, and I can do that either by
> adding the form with javascript (hard coding it in javascript and
> requesting from the server via AJAX the information from the database)
> or by making a request to the controller and load the form.
>
> Which one do you think is better from the best practices point of
> view?
>
> Thank you in advance!
>
> --
> Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
> Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
>
>
> To unsubscribe from this group, send email to
> cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Monday, June 25, 2012
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment