Here is one thing I don't quite understand while using $ajax->observeField :

I created a dropdown populated with a list of countries like so ...

echo $html->tableCells(array('<b>Country:</b>', $form->input('country',
array($countries, 'empty' => '-- Select --', 'label' => ''))));
$options = array('url' => 'countrySelect','update' => 'countryAction');
echo $ajax->observeField('UserCountry', $options);

When a country is selected it does what I would expect and creates another
input for "Region" ...

echo $html->tableCells(array('<b>Region:</b>, $form->input('region',
array($regions, 'label' => '', 'empty' => '-- Select --'))));

The part I don't understand is that when I echo debug($regions) it displays
an array of regions as I intended however it is not populating the new
dropdown with the array.

If the script is making it far enough to go ahead and create the "region"
field and the $region array is not empty ... why would it not populate the
dropdown with the array ??


On Mon, Mar 22, 2010 at 5:05 PM, Ed Propsner <crotchf...@gmail.com> wrote:

> Cake and MVC can be a bit daunting for the first time around especially
> when having spent years with conventional code, nothing fancy. I re-wrote my
> Ajax calls and the best I can say is that I didn't have something scripted
> correctly the first time around because Chrome Java Console and FireBug both
> now report that the element is indeed empty.
>
> For the first field I am (was) using $ajax->observeField for field 1. In
> the event that field 1 changed, it creates field 2 accordingly and so on
> down the line with fields 3,4, etc.
>
> I can tell you right off the bat that my problem is ignorance. This all
> feels so alien to me.
>
> I initially had it set up with "onchange" in the options array as you
> suggested. I'm trying to stick with Cake conventions but my first
> inclination was go straight for the head of my default.ctp and start with
> <script type=" ..... ..... ..... new Ajax.Updater ... etc. Force of habit I
> suppose. I'm a tad bit thrown off with controllers, actions, views, etc.
> even though the concept does make sense. Let's say I did want to use
> "onchange" ... where would I put the actual function and what syntax should
> I use? This is the part that is throwing me off.
>
>
> On Mon, Mar 22, 2010 at 5:13 AM, WebbedIT <p...@webbedit.co.uk> wrote:
>
>> This is probably a mute point as you say your other sites are ajax
>> heavy, but what are you using to view the source.  I would suggest
>> something like FireBug as it shows the full source including DOM
>> changes via ajax/javascript.  It will also show you the results of
>> your ajax requests.  You should of course already be using something
>> similar to FireBug if you have been working with ajax a lot in the
>> past.
>>
>> How have you set up a javascript event for the 1st dynamic field your
>> form creates?  My first guess is your adding an observer for the 2nd
>> field before it exists in the dom. You can also add an
>> 'onchange'=>'jsfunction()' to the options array of form->input to add
>> events to your form fields, this would attach the event to the field
>> as it's created.
>>
>> HTH
>>
>> Paul
>>
>> Check out the new CakePHP Questions site http://cakeqs.org and help
>> others with their CakePHP related questions.
>>
>> 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<cake-php%2bunsubscr...@googlegroups.com>For
>>  more options, visit this group at
>> http://groups.google.com/group/cake-php?hl=en
>>
>> To unsubscribe from this group, send email to cake-php+
>> unsubscribegooglegroups.com or reply to this email with the words "REMOVE
>> ME" as the subject.
>>
>
>
>
> --
> Please visit http://freecupidreport.com
>

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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

To unsubscribe from this group, send email to 
cake-php+unsubscribegooglegroups.com or reply to this email with the words 
"REMOVE ME" as the subject.

Reply via email to