sorry, a typo, I think the $js should be spelled echo Bottom instead
of bottom and 'echo' before the $javascript->codeBlock... Do not
forget to change the update div to datacontrol in your ajax->submit
On Jun 13, 11:17 pm, francky06l <[EMAIL PROTECTED]> wrote:
> you could use another div that would encapsulate jscode coming from
> your controller to update the "data" div.
> Using javascript such as insertion would allow you to insert data at
> the bottom of the "data" div.
>
> /**example template code **/
> <form onSubmit="return false;">
> <?php foreach ($tests as $test): ?>
> <?php echo $html->Checkbox('Test/'. $test['Test']['id']); ?>
> <?php endforeach; ?>
>
> <?php echo $ajax->submit('Add Data To Div Below', array('url'
> =>'ajaxAddTests', 'update'=>'datacontrol')); ?>
> </form>
>
> <div id="data">
> <h1> test data here </h1>
> </div>
>
> <div id ="datacontrol">
> </div>
>
> The ajaxAddTest.thtml could look like this (you can use any variable
> set in controller for your data):
>
> <?php
> $ajax->div('datacontrol');
>
> $js = "new Insertion.bottom('data', '<h1>My new data</h1>');";
> $javascript->codeBlock($js, false);
>
> $ajax->divEnd('datacontrol');
> ?>
>
> Hope this helps
>
> On Jun 13, 10:32 pm, Dustin Weber <[EMAIL PROTECTED]> wrote:
>
> > I've done quite a bit of reading on this, but I'm still a little vague
> > about how to achieve what I want. Here's some example code to start
> > out with:
>
> > /**example template code **/
> > <form onSubmit="return false;">
> > <?php foreach ($tests as $test): ?>
> > <?php echo $html->Checkbox('Test/'. $test['Test']['id']); ?>
> > <?php endforeach; ?>
>
> > <?php echo $ajax->submit('Add Data To Div Below', array('url'
> > =>'ajaxAddTests', 'update'=>'data')); ?>
> > </form>
>
> > <div id="data">
> > <h1> test data here </h1>
> > </div>
> > /** END example template code **/
>
> > So basically, in this simplified example, I'm parsing through the
> > check boxes in the form through the "ajaxAddTest" action. After doing
> > some work depending on which check boxes were selected, the action
> > renders the "ajax_add_tests" view to the "data" div directly below the
> > form. This could be any kind of data, it's not really important.
>
> > That part works properly, but it always overwrites the "data" div. I
> > need it to take what's in the data div and either prepend or append
> > the new data to it. In simple terms, I'd like it to push the data
> > down and put the new stuff at the top.
>
> > IMPORTANT: The user can push the ajax->submit button many times with
> > many combinations of checked boxes. Each time, I need it to just push
> > the data down and never overwrite anything.
>
> > I've come up with different solutions to solve the problem, but none
> > seem very elegant or simple. I'm assuming the easiest solution
> > would be to grab the existing innerHTML somehow and append it onto the
> > new data coming in. Another way would be to simply create a new div
> > each time data is submitted.
>
> > Regardless, any help (with code examples) would be greatly
> > appreciated! I know I'm probably missing something obvious here, so
> > my apologies if this is an easily solved problem.
>
> > - Dustin Weber
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---