To do this I use the Rossoft CJS (snippet from cakeForge). It works
very well with cake 1.1, for 1.2 I use the js helper.
Anyway to do this you need to add an hidden row at the end with an id
such as :
<td id="lastrow" style="display:none;"></td>
and also an hidden div that your ajax call will update (if you use the
CJS, it does it for you).
You ajax request should then replace the id 'lastrow', by a new + a
new hidden row. Using Cjs would give something like this :
file update.cjs
<?php
$v = '<td>Project title</td><td id="lastrow" style="display:
none;"</td>';
echo $page->replace('#lastrow', $v);
?>
For 1.2 is a bit different, but the concept is identical.
hope this helps
On May 17, 5:11 am, pete <[EMAIL PROTECTED]> wrote:
> hi,
> i downloaded and tested the ajax example
> fromhttp://demo.grahambird.co.uk/tasks
> everything works fine. now im trying to do the same with a table.
> after clicking on 'Add task' a new row should be added to the table.
> could anyone help me out? it works fine with divs but not with a table
>
> thanks
>
> pete
>
> CONTROLLER
> var $helpers = array('Html','Javascript','Ajax','Form');
> function add()
> {
> $this->Project->saveProject();
> $this->set('data', $this->Project->findAll());
> $this->render('todo', 'ajax');
>
> }
>
> VIEW
> <div id="add_task">
> <form onSubmit="return false;">
> <?php
> print $html->input('Task/title', array('id' => 'add_input'));
> print $ajax->submit('Add task', array('url' => 'add',
> 'update'=>'tasks_todo'));
> ?>
> </form>
> </div>
>
> <table border="1" width="100%">
> <?
> foreach ($data as $row)
> {
> $item = $row['Project'];
> ?>
> <tr>
> <td><? echo $item['ProjectTitle']; ?></td>
> </tr>
> <?}
>
> ?>
> </table>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake
PHP" 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
-~----------~----~----~----~------~----~------~--~---