Working with cakephp 1.2 here.  I have a somewhat simple problem that
I can't seem to resolve with what I've found so far in the GG's..

I have a simple page that submits a "task" via AJAX.  This form
contains the unobtrusive date picker (http://bakery.cakephp.org/
articles/view/using-the-unobtrusive-date-picker-widget-in-cakephp).

---------------------------------------------------------------------------------
Layout header contains the necessary JS:
<?php
if (isset($javascript)) {
echo $javascript->link('scriptaculous/protoculous-packer.js');
echo $javascript->link('datepicker/datepicker.js');
}
?>
---------------------------------------------------------------------------------
The view looks something like this [add_task.ctp]:

<?php echo $ajax->form(array('action' => '/Tasks/addTask'), 'post',
array('update' => 'task')); ?>
<div id="task" style="display: none;">
                <?php echo $form->input('text', array('label' => false)); ?>
                 <?php echo $form->input('Task/dateOnly', array('size' => '15',
'class' => 'w8em format-m-d-y divider-dash highlight-days-12 no-
transparency', 'label' => false));?>
                 <?php echo $form->hour('Task/time'); ?>
                 <?php echo $form->minute('Task/minute'); ?>
                 <?php echo $form->meridian('Task/meridian'); ?>
                <?php echo $form->input('category', array('label' => false)); ?>
        </p>
        <?php echo $form->submit('Add Task'); ?>
</div>
</form>
---------------------------------------------------------------------------------

The ajax view looks like this [ajax_add_task.ctp]:

<?php echo $form->input('text', array('label' => false)); ?>
                 <?php echo $form->input('Task/dateOnly', array('size' => '15',
'class' => 'w8em format-m-d-y divider-dash highlight-days-12 no-
transparency', 'label' => false));?>
                 <?php echo $form->hour('Task/time'); ?>
                 <?php echo $form->minute('Task/minute'); ?>
                 <?php echo $form->meridian('Task/meridian'); ?>
                <?php echo $form->input('category', array('label' => false)); ?>
        </p>
        <?php echo $form->submit('Add Task'); ?>
---------------------------------------------------------------------------------

The initial page load of the above code works just fine.  The
datepicker shows up just fine and all is well.  When the form submits
(via ajax), I want it to add the task and then return the same fields
again... so the user can add many task quickly and easily.

However, when the form comes back after the ajax call, the datepicker
piece is missing.  I understand this has to do with the fact that the
the original datepicker JS isn't being executed when the we do an ajax
layout, so I probably need to use the 'onComplete' ajax option to
restart the script again.  However, I can't get the onComplete to work
at all.  It never fires off anything (I even just tried basic
alerts).

I was using the following context:
<?php echo $ajax->form(array('action' => '/Tasks/addTask'), 'post',
array('update' => 'task', 'onComplete' => "alert('test');")); ?>

When the ajax task completes, nothing happens (the alert doesn't show
up in the source code anywhere).

Also, I tried simply including the datepicker.js file in the ajax view
itself as well (thinking it might be executed), but no luck there
either.


Any ideas would be greatly appreciated!

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