Tuesday, December 22, 2009

Re: Ajax reload of an element from a call within the element itself

Arrrghhh.
Ok my whole understanding was wrong, thanks Jeff !
I thought Cake could by himself refresh the element content in the
view.

I didn't get that the function in the controller would only return the
content, and that I had to update/refresh the element with the result.

Thanks !

On Dec 20, 1:18 am, Jeff Deroshia <deros...@gmail.com> wrote:
> Probably a couple of things.  First, I would remove the onclick argument
> from $html->link() and return false from the jquery function.  Second, I
> think you need to supply a callback function in your $.post() call to update
> whatever element in the dom you want.  Currently, it looks like cake is
> rendering a view, but the jquery $.post() function isn't doing anything with
> the returned view markup.
>
> Jeff
>
>
>
> On Sat, Dec 19, 2009 at 1:52 PM, Laurent Kretz <laure...@gmail.com> wrote:
> > Hi all !
>
> > I'm trying to reload an element inside a view, and having troubles...
> > I read the two following similar posts without finding a solution:
>
> >http://groups.google.com/group/cake-php/browse_thread/thread/6d69e85b...
>
> >http://groups.google.com/group/cake-php/browse_thread/thread/600c9f20...
>
> > Also been browsing the library, the cookbook, ... So maybe I'm missing
> > something.
>
> > So: I have a view, inside that view I have an element, and inside that
> > element i have a jquery ajax link to reload the element itself.
>
> > * Inside the element: *
> > echo $html->link(
> >        'Test!',
> >        '#',
> >        array(
> >            'onclick' => 'return false;',
> >            'id' => 'test'
> >        )
> >    );
>
> > * The jQuery on click call: *
> > $('#test').click( function () {
> >    $.post('/comments/test', {id: $(this).attr('id')});
> > });
>
> > * The test function in the controller: *
> > function test() {
> >    if($this->RequestHandler->isAjax()) {
> >        $this->viewPath = 'elements'.DS.'comments';
> >        $this->render('simplecomments');
> >    }
> > }
>
> > What am I missing here ?? I'm a noob, sorry if the question is
> > trivial ;)
>
> > 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 cake-php@googlegroups.com
> > To unsubscribe from this group, send email to
> > cake-php+unsubscribe@googlegroups.com<cake-php%2Bunsubscribe@googlegroups.c om>For more options, visit this group at
> >http://groups.google.com/group/cake-php?hl=en

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 cake-php@googlegroups.com
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?hl=en

No comments: