Hi,
1.
place $this->render('your ajax view'); into controller
deleteattachment() function

2. you can add your variables to url
will look like
array('controller' => 'linkables', 'action' => 'deleteattachment',
param1,param2

and it will be available in the controller as $this->params.

try to pr($this); to see all available data;

On Sep 9, 3:01 pm, Tomfox Wiranata <tomfox.wiran...@gmail.com> wrote:
> hi,
>
> again, ajax is driving me nuts. shocker! :)
>
> I have a certain DIV that echoes data from a table. with each data row
> comes an ajax link to delete it. when a user clicks that link, a
> delete() function in my controller deletes that certain data and this
> DIV is supposed to update. I found some code for orientation, but it
> wont work.
>
> the View "render_attachment.ctp" echoes the data from my table and has
> the ajax link:
>
> <?php
>
>     echo $javascript->link('prototype');
>     echo $javascript->link('scriptaculous');
>
> ?>
>
>         <?php
>
>                 foreach ($attachments as $attachment):
>
>                 echo $attachment['LinkTmp']['name'];
>                 echo $ajax->link('x', array('controller' =>
> 'linkables', 'action' => 'deleteattachment'), array('update' =>
> 'attachment_div'));
>
>         ?>
>
>                 <?php endforeach; ?>
>
>         <div id="attachment_div"></div>
>
> the render_attachment.ctp View is called after a file-upload-process
> to show the user what files he uploaded:
>
>     function __renderattachment()
>     {
>         $this->set('attachments', $this->Link->LinkTmp->find('all',
> array('conditions' => array('LinkTmp.ed =' => $this -> Session ->
> read('Link.eyed'), 'LinkTmp.attachment' => '1'))));
>         $this->render('render_attachment','ajax');
>     }
>
> Now with the ajax link I try to call the "deleteattachment()" fnction
> in my controller, that acutally deletes that data from the table:
>
>         function deleteattachment($name)
>         {
>                 $this->Link->LinkTmp->deleteAll(array('LinkTmp.eyed' => $this 
> ->
> Session -> read('Link.eyed'), 'LinkTmp.name'  => $name));
>
>         }
>
> so, how do I
>
> a) tell cake to render my view "render_attachment.ctp" in the DIV that
> i defined in the link, after i called deleteattachment() ?
>
> b) how can i pass variables to deleteattachment() with my ajax link?
>  echo $ajax->link('x', array('controller' => 'linkables', 'action' =>
> 'deleteattachment'), array('update' => 'attachment_div'));
>
> thx :)

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