Re: Ajax in Cake -> Javascript Response

2008-03-02 Thread mason k

You'll probably get more helpful responses if you explain what you're
trying to do in English, rather than in code, particularly a code, the
understanding of which, is predicated on the knowledge of a syntax and
methodology which is not part of the Cake universe.

Also: Cake 1.1 or 1.2?   Though the CakePHP documentation is not on
the same level as Rails documentation, there is a manual which
explains quite a lot.  The manual is at http://manual.cakephp.org for
Cake 1.1, and http://tempdocs.cakephp.org/#TOC12047 for Cake 1.2.

Here's the gist of Ajax in Cake.

1.  Ajax updating of web pages is handled by the integration of the
Prototype.js and Scriptaculous.js libraries.
2. Integration of the libraries if achieved by use of the AjaxHelper,
and the inclusion of the RequestHandler component.  Read the manual to
learn how to include Helpers and Components in your code.
3. I don't know Rails, but I know ruby, so I am taking a stab at your
question in particular.
a. It sounds like the method you want is AjaxHelper::Link (make sure
to  the js files in your layout or view).
b. (Learn bout AjaxHelper at http://api.cakephp.org/1.2/class_ajax_helper.html
<- This is the API.  You have to learn to love it.)
c. You call this method in the view with $ajax->link.

Hope this helps

On Feb 29, 9:49 am, MarcS <[EMAIL PROTECTED]> wrote:
> Hi all,
>
> I'm pretty new to cake. I previously used rails for my project but due
> to the requirements of my current project php will have to be used and
> I therefore opted to use Cake.
>
> I was not able to find very good information about how to get Ajax to
> work the way I want to.
> In rails I could have something like this in my controller
>
> render :update do |page|
>page.remove "dom_element"
>page.insert_html :after, 'some_element', :partial =>
> 'line_item', :object => @variable_for_partial_rendering
> end
>
> Is there an easy way that I can do this kind of Javascript responses
> in Cake?
>
> thanks,
>
> Marc

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
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
-~--~~~~--~~--~--~---



Re: cakephp 1.2 form

2008-02-24 Thread mason k

Thanks for the answer, but I'd love a little more guidance myself.
Can you answer OP's Q1, which is the difference between $ajax->form
and $ajax->submit?

Also, please explain the $this->render('view','ajax'); line of code?
There is nothing in the API (http://api.cakephp.org/1.2/
class_controller.html#90046e6b62c91452a987c9573372c2ac) about a
special 'ajax' value as a layout option.  What does this do?  Does it
render no layout if the request was ajax?  How does the action know
whether an incoming request is coming from an Ajax source or not?


On Feb 23, 4:54 pm, "b logica" <[EMAIL PROTECTED]> wrote:
> Try this to close your controller action:
>
> $this->render('VIEW', 'ajax');
>
> where VIEW is the name of your view. (or element?)
>
> On Sat, Feb 23, 2008 at 12:30 PM, brammeleman <[EMAIL PROTECTED]> wrote:
>
> >  I'm trying to create a simpleAjaxbasedform. These are the steps
> >  I've taken along with the questions that came up:
>
> >  I've managed to get the forms' content into a div element. Done by
> >  creating an 'ajax' instead of an 'html' link. When I submit theform,
> >  I get redirected back to the index view showing the modified or added
> >  record. All fine!
> >  But, when theformvalidation fails, I get redirected to theform
> >  directly rendered into the layout (instead of in the div element).
>
> >  To solve this problem, I've replaced the $form->create helper call by
> >  the $ajax->formhelper call in theformview.  Telling the $ajax->form
> >  function to update the div element.
>
> >  Q1) what's the difference in using $ajax->formand $ajax->submit?
> >  should one of them be used exclusively? or do they need to be used in
> >  a pair (like $form->create and $form->end)?
>
> >  Now it works nice when theformvalidation fails. But when the
> >  submitted data validates, the redirected (index) page gets rendered in
> >  the div. The funny thing is that somehow the requesthanler doesn't
> >  know it's anajaxrequest. It renders the content in the default
> >  layout.
>
> >  I'm obviously missing the point somewhere
> >  Q2) how can you make sure thatformstays in the div, but when it
> >  validates you get a non-ajaxredirect?
>
> >  Thanks for your help,
>
> >  Bram
>
> >  ps: someone else apparently posted a similar question in the bin:
> >  http://bin.cakephp.org/saved/521

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
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
-~--~~~~--~~--~--~---