Hi

I'm fairly new to cakePHP and have been working on trying to use the
Ajax helper to update 2 or more divs from a single button press.

I've been using this tutorial http://www.reversefolds.com/articles/show/ajax

Which I can get to work with my cake install (1.2), but I think its
designed for an older version of cakePHP.

Using the methods involved in updating 2 divs, I can recreate the
example with my own code. However, I seem to run into problems when I
want to loop through the initial data that is prvoided to the view.

Its a bit difficult to explain. But basically I want to loop through
the model data in the inital view, display it with 2 updateable divs
per line of data, and then each line will have a different ajax link,
with the link specifying the 2 divs on that particular line.

Example of the view code - this works correctly, and is contained in a
view called test.

<?php for($i=1;$i<4;$i++)
{
        echo $ajax->link('Click Me', '/model/test2/',
                 array('update' => array("change_me_1_{$i}",
"change_me_2_{$i}"))
                );
?>
        <?php echo $ajax->div("change_me_1_{$i}");?>
                Value 1:<?php echo $value1?>
        <?php echo $ajax->divEnd("change_me_1_{$i}"); ?>

        <?php echo $ajax->div("change_me_2_{$i}");?>
                Value 2:<?php echo $value2?>
        <?php echo $ajax->divEnd("change_me_2_{$i}"); ?>
<?php
}
?>

The code for the 'test2' call in the controller is simply

<?php
$this->set('value1',rand(0,1000));
$this->set('value2',rand(0,1000));

$this->layout = 'ajax';
Configure::write('debug','0');
$this->render('test');
?>

But if I change the for loop for an foreach which uses the model data,
then it dosn't work. Even changing the '4' for a variable which is the
sizeof() my model data dosn't work.

There is no difference at all in between the views when changing the
way the loop works.

I've used firebug to see what data I'm getting back. When it works I
get javascript with CDATA in it. When it dosn't work I get the html
for the view back.

I'm not sure where else I can look to debug this. Any ideas what may
cause this? And is there a decent tutorial/example of this sort of
thing?

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