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 [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

Reply via email to