Hey guys,
my problem is, that the ajax validation on a form doesn’t work at all and I can’t figure out, where the bug is hiding.
Short: the ajax POST isn’t sent to the server.
My view, where the form is placed in looks like this:
<div class="form">
<?php
$form = $this->beginWidget('CActiveForm', array(
'id' => 'comment-form',
'enableAjaxValidation' => true,
));
?>
<div id="comment_dialog_box<?php echo $entry->entry_id; ?>"></div>
<?php echo $form->errorSummary($model); ?>
<div class="row" class="input_field">
<span style="font-size:20px; color:#000; float:left; margin:10px 5px 0 0;">Wie sehen Sie das? </span>
<span style="float:right;">
<?php echo $form->textArea(Translation::model(), 'content', array('rows' => 1, 'cols' => 50, 'class' => 'input_focus', 'id' => 'comment_textArea' . $entry->entry_id, 'entry_id' => $entry->entry_id)); ?>
<?php echo $form->error(Translation::model(), 'content'); ?>
</span>
<div style="clear:left; clear:right;"></div>
</div>
<div class="row buttons input_buttons" id="input_button<?php echo $entry->entry_id; ?>" style="float:right;">
<?php echo CHtml::activeHiddenField($entry, 'entry_id'); ?>
<?php
echo CHtml::ajaxLink('Abbrechen', '', array(), array('id' => 'cancelButton' . $entry->entry_id)) . ' ';
echo CHtml::ajaxSubmitButton('Posten', $this->createUrl('comment/create'), array('update' => '#comment_dialog_box' . $entry->entry_id));
?>
</div>
<div style="clear:right;"></div>
<?php $this->endWidget(); ?>
</div><!-- form -->
so the "enableAjaxValidation" is set to true.
The controller functions etc. shouldn’t matter, because like I said, the POST isn’t even sent.
My thought is, that it has something to do with the jquery stuff, but even here I played around and couldn’t find a solution.
My "jQuery-situation" is as follows:
in my config/main.php I deactivated all the jQuery files to load them from google:
...
'components' => array(
'clientScript' => array(
'scriptMap' => array(
'jquery.js' => false,
'jquery.min.js' => false,
'jquery.ajaxqueue.js' => false,
'jquery.metadata.js' => false,
),
),
...
in my themes/.../views/layouts/main.php the situation is as follows:
...
<?php echo CGoogleApi::init(); ?>
<?php
echo CHtml::script(
CGoogleApi::load('jquery.min', '1.6')
);
?>
<script>window.jQuery || document.write('<script src="<?php echo Yii::app()->theme->baseUrl; ?>/js/jquery-1.6.1.min.js">\x3C/script>')</script>
...
so I’m loading the jQuery.min from google and as fallback option I’m loading my own jQuery.min. (If anyone got a better or smoother solution here … I’m happy for comments here as well ;-))
If I look at the network stuff in firebug the following files are loaded:
1744
Maybe I took a wrong turn with searching the problem at the jQuery stuff, I’m wide open for other ideas …
I just can tell again: when I set the focus in the edit field of the form (it just has one field) and than remove the focus … no POST is sent.
Thanks a lot in advance,
Mayjestic