On Jul 9, 5:03 pm, Sir Tabs <[EMAIL PROTECTED]> wrote:
> Thanks for the help Mark. Answered my questions, and I'm that much
> closer to figuring out what I'm after.
>
> I guess as a follow-up, I'm curious about using $this->render(). I'm
> playing around with an $ajax->form(), and I just want to take the
> information submitted in the text area and update a <div> on the same
> page with the submitted text. The <div> just happens to be the view
> for my "/clients/add." (Eventually I want to update the form via Ajax
> if there are validation errors - but I'm not quite there yet.
> So, if I want this "/clients/ajaxUpdate" to update the special <div>
> on the "/clients/add" view, do I want to use the $this->render('add',
> '--layout-file--') to make it spit up the proper, updated view on my
> "add" view?
Well you should have an view for ajaxUpdate as the Javascript can get
the contents of that page fragment and insert it into the DOM where
the div is. When using ajax and non ajax requests. You should really
look into using the RequestHandler component as it will help switch
layouts and change output types if need automatically.
> Currently it gives me a "Missing View - ajaxUpdate view filing
> missing" because of course I don't have and don't need a separate view
> for my "ajaxUpdate" action. I think this is just because I have my
> debugging parameter set to display every warning. However, maybe I'm
> missing another cake convention.
> Is there a proper way to get one action to update the contents of
> another action's view? Besides for $this->render()?
I just let the ajax requested action render an html fragment and jam
that back into the dom when the request is done. so ajaxUpdate would
need a view file, and since the ajax layout is an empty layout that is
all that will be returned.
> -Thanks again
>
> On Jul 9, 11:44 am, mark_story <[EMAIL PROTECTED]> wrote:
>
> > On Jul 8, 4:37 pm, Sir Tabs <[EMAIL PROTECTED]> wrote:
>
> > > Two simple questions, with hopefully easy answers:
> > > ----------------------------
> > > 1) The render() function and it's paramaters
> > > ---------------------------
>
> > > I've been reading forums, snippets of code, this group and the API,
> > > and I still get confused by the use of the render() function used by
> > > controllers.
>
> > > Documentation would suggest that it's:
>
> > > $this->render($action, $layout, $file);
>
> > > Where $action is an action/function/something?
>
> > $action would refer to the controller action you are rendering ie.
> > index, add etc. That is the view file that will be loaded if $file is
> > not filled out.
>
> > > I've seen in another post that it's more like:
>
> > > $this->render('myView', 'myLayout');
>
> > > This makes more sense to me. Does $action really just imply the view
> > > that's associated with the that particular action?
>
> > usually yes.
>
> > > I know it's a simple question, but it seems a lot of the official
> > > documentation is written by people very familiar with their own code -
> > > which makes it harder for a cakeNoob like me to learn cake.
>
> > > I would have explored this on my own with experimentation, but I'm
> > > trying to use it in context of the $ajax->form() method, but am a long
> > > way off from learning how to use that successfully.
>
> > > ------------------------------
> > > 2) An 'ajax' layout?
> > > ------------------------------
> > > Whenever I see the snytax " $this->render($action, $layout) " , I see
> > > most people use 'ajax' for the layout parameter (usually because they
> > > are using the render method along with some Ajax action). My question:
> > > is there a universal 'ajax' layout? If so, or even if not, what would
> > > a typical 'ajax' layout look like?
>
> > There is a default ajax.ctp in layouts. You can find it in cake/libs/
> > view/layouts/ajax.ctp Copying it to your app/views/layouts will allow
> > you to override and change it.
>
> > > Thanks for the help -
> > > Hopefully it won't be too long before I can provide some help back to
> > > the community at large.
>
> > -Mark
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---