On Sun, Mar 30, 2008 at 1:10 AM, dupor <[EMAIL PROTECTED]> wrote:
>  I did this, but have problem when I click on button "add Address"
>  fast.
>  so I become two Address4 instead of Address4 and Address5
>
>  How You solve this. Semaphore or something? but where?
>  Now I have counter in code which I'm changing...

Here's how I attacked it:

1) set a variable in the view that is what the *next* index of
multiple Address fields would be
2) pass that value to my Ajax call so that the Cake action correctly
created the form.

Here's what I mean

If I have

echo $form->input('User.address.1', ...)

as my current address, when I make my Ajax call I'd do something like

controller/addAddress/id/2

and put the value of id into a variable called $id

and make sure that controller/addAddress outputs a view that would do

echo $form->input("User.address.{$id}", ...)

Add add that bit of HTML into the DOM *after* my first address input
box.  With some smart naming of elements and DOM construction, this
should be very simple to do.

Hope that helps.

-- 
Chris Hartjes
Internet Loudmouth
Motto for 2008: "Moving from herding elephants to handling snakes..."
@TheKeyBoard: http://www.littlehart.net/atthekeyboard

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

Reply via email to