Is it possible?
view:
<div class="form">
<?php $model = new Newslettersubscribe; ?>
<?php $form=$this->beginWidget('CActiveForm', array(
'id'=>'newslettersubscribe-form',
'action'=>array('hirlevel/feliratkozas'),
'enableClientValidation'=>true,
'enableAjaxValidation'=>true,
'clientOptions'=>array(
'validateOnSubmit'=>true,
),
)); ?>
<?php echo $form->textField($model,'email', array('title'=>'Add meg email címed, hogy értesülj az oldallal kapcsolatos hírekről')); ?>
<?php echo CHtml::ajaxSubmitButton(
'Elküld',
array('hirlevel/feliratkozas'),
array(
'success'=>'function(data) {
$("#newslettersubscribe-form").children("input[type=text]").val("");
$("#resultAjax").html(data);
fadenotification();
}'
),
array('class'=>'superbutton')
); ?>
<div class="row alignleft">
<?php echo $form->error($model,'email'); ?>
<div id="resultAjax"></div>
</div>
<?php $this->endWidget(); ?>
</div><!-- form -->
controller:
public function actionFeliratkozas() {
$model = new Newslettersubscribe;
$this->performAjaxValidation($model);
if(isset($_POST['Newslettersubscribe'])) {
$model->attributes = $_POST['Newslettersubscribe'];
if($model->validate()) {
if($model->save()) {
if(!Yii::app()->request->isAjaxRequest) {
Yii::app()->user->setFlash('success', 'Sikeresen feliratkoztál a hirlevélre.');
$this->refresh();
} else {
echo $this->Createflash('success', 'Sikeresen feliratkoztál a hirlevélre.');
}
}
}
}
if(!Yii::app()->request->isAjaxRequest) {
$this->render('subscribe', array(
'model'=>$model
));
}
}
If i use, the ajaxsubmit always send the data-s to controller. How to use the 2 jquery code?