On Fri, Jan 2, 2009 at 7:45 PM, Steven Wright <[email protected]> wrote:
>
> 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.
>

Being a jQuery user, I never bother with Cake's ajax() stuff. But
jQuery is dead simple (mostly) to use, so I don't mind having to write
out a few lines of JS. To do what you describe, I'd do something like
this:


$(document).ready()
{
        $('#the_button').click(function()
        {
                $.ajax({
                        url: the_href,
                        type: 'GET',
                        data: the_data,
                        dataType: 'html',
                        timeout: 2000,
                        error: function(XMLHttpRequest, textStatus, errorThrown)
                        {
                                // ...
                        },
                        success: function(msg)
                        {
                                /* assuming your controller is returning 
'<tr>...</tr>'
                                 */
                                $('#the_table').append(msg);
                        }
                });
        });
});

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