Friday, January 2, 2009

RE: Adding table row with AJAX

Hi Adam,
Thanks for writing back. How would you get the data back for the row from
CakePHP?

My row contains four columns with the following inputs:

amount [text]
measurement_type [select]
description [text]
ingredient [select]

This is normally rendered from an element as a table row. I would like the
output of that element appended to my table. So on the button click I call
the action add_ingredient_row and it should return the content of the
element. How do I get that content appended to my table.

I can do this without CakePHP. But for me this exercise is to use the
framework.

Thanks
Steve


-----Original Message-----
From: cake-php@googlegroups.com [mailto:cake-php@googlegroups.com] On Behalf
Of Adam Royle
Sent: Friday, January 02, 2009 7:09 PM
To: CakePHP
Subject: Re: Adding table row with AJAX


It is my understanding that CakePHP is planning to migrate to jQuery in the
near future (much like the rest of the world, even my grandmother, and she
doesn't even have a computer!).

I use jQuery to add an extra row by cloning the last row, incrementing the
ids and names of the elements and appending it to the container.
Works very well without the need for any "ajax".

Cheers,
Adam

On Jan 3, 7:31 am, "rhythmicde...@gmail.com" <rhythmicde...@gmail.com>
wrote:
> Can someone please give me some pointers on this? I have a table. I
> have a button that when clicked should called an action. That action
> should return the HTML for a new row. The row should then be appended
> to the table.
>
> If I use 'update' in the options array the entire content of the page
> is put inside the row.
> If I use 'append' in the options array nothing happens.
>
> echo $ajax->link('Click Here', 'edit/', array('update' => 'mytable'));
>
> I have looked through the manual and found nothing. I reviewed the API
> and followed the link to the definition of ajax->link but did not find
> anything to help.
>
> I have been advised to use jQuery. But I want to make it work with
> what CakePHP recommends.
>
> Thanks for any help.
>
> VIEW
>
> <h2>Testing AJAX with CakePHP and Prototype and Scriptaculous</h2>
>
> <table id="mytable">
>         <tr id="row1">
>                 <td>Row1</td>
>         </tr>
> </table>
>
> <div id="mydiv">
> This is a div
> </div>
>
> <?php
>         echo $ajax->link('Click Here', 'edit/', array('update' =>
> 'mytable')); ?>
>
> ACTION
>
>         function edit()
>         {
>                 $this->pageTitle = 'Edit Page';
>                 if($this->RequestHandler->isAjax())
>                 {
>                         $this->layout = 'ajax';
>                         echo '<tr><td>This is a row</td></tr>';
>
>                 }
>         }


--~--~---------~--~----~------------~-------~--~----~
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: