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/6d69e85b884d4e40/f9fcd5de2c526a52
>
> http://groups.google.com/group/cake-php/browse_thread/thread/600c9f2005a4419f/06de1a575220b80c
>
> 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 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+unsubscr...@googlegroups.com<cake-php%2bunsubscr...@googlegroups.com>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+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en

Reply via email to