Well, I don't know how I ever got along without Firebug! Thanks for
that Dave!!
The good news is I found a workaround (at the very bottom here). The
not so good news is that it looks like if you're updating multiple
elements as part of an ajax request and you're complete callback
depends on the values in the updated elements, you can't use the
'complete' option. Unless someone has already discovered this and
knows how to get it to work?
So, here's what I've found. Because I'm updating multiple elements
with the ajax call, the response text that's generated is a javascript
code bock:
<script type="text/javascript">
//<![CDATA[
var __ajaxUpdater__ = {name_div:"1",
pstyle_div:"%3Cselect%20name%3D%22data%5BProductStyle%5D%5Bid%5D
%22%20id%3D%22pstyle_sel%22%3E%0A%3Coption%20value%3D%228%22%3EChunk%3C
%2Foption%3E%0A%3C%2Fselect%3E"};
for (n in __ajaxUpdater__) { if (typeof __ajaxUpdater__[n] == "string"
&& $(n)) Element.update($(n), unescape(decodeURIComponent
(__ajaxUpdater__[n]))); }
//]]>
</script>
This script code is generated by AjaxHelper.afterRender(). So, after
prototype.js has 'complete'd it updates a temporary div (output by
$ajax->observeField()) and calls the callback function - my updateInfo
(). It seems that although the request is 'complete' my callback is
being invoked before the javascript code from the ajax response is
evaluated/executed.
So, here's my workaround. Instead of specifying a callback for
'complete' in observeField(), I added the javascript code block to the
div that's getting updated.
Here's the observeField() code:
echo $form->select
('Brand.id',
$brands,
null,
array( 'id' => 'brnd_sel'),
'Choose Department');
$options = array('url' =>
'/test/getdata',
'update' => array('name_div', 'pstyle_div'),
'type' => 'asynchronous',
'indicator' => 'loading');
echo $ajax->observeField('brnd_sel',
$options);
And here's one of the div's that's getting updated:
<tr id="product_style_dsp">
<td class="label">Product Style:</td>
<td>
<?php
echo $ajax->div('pstyle_div');
echo $form->select('ProductStyle.id',
array($pstyle_options),
null,
array('id' =>
'pstyle_sel'),
null);
echo $javascript->codeBlock("
if
($('pstyle_sel').options.length == 0)
$('product_style_dsp').hide();
else
$('product_style_dsp').show();
");
echo $javascript->blockEnd();
echo $ajax->divEnd('pstyle_div');
?>
</td>
</tr>
--
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=.