Hi All…
I am working on a page and using radioButtonList for showing three radioButtons and on clicking the radio button an ajax request is fired. Now the problem is that once I select any of the radio button it gets selected and a request is fired but if i click on any of the radio button again that radio button doesn’t get selected .The ajax request is getting fired according to the selected radio button every time but it is not getting shown as selected… Below I am giving the code as well. PLease help
<?php
$reportType = array();
$reportType[1] = 'Reports';
$reportType[2] = 'SMS Alert for critical alarms';
$reportType[3] = 'Complete IR';
$select ='';
?>
<div class="form">
<?php $form=$this->beginWidget(‘CActiveForm’, array(
'id'=>'machine-alert-and-report-details-form',
'enableAjaxValidation'=>false,
)); ?>
<table border="0" cellpadding="0" cellspacing="0" class="sumInfo difective-info faqCreate">
<tr>
<td colspan ="3"><?php echo CHtml::label('Reports*','reports',array()); ?></td>
</tr>
<tr>
<td><?php echo CHtml::radioButtonList('reports',$select,$reportType,array('ajax'=>array('type'=>'POST','url'=>CController::createUrl('reportDetails/getform'),'update' =>'#reportForm') ,'class' =>'select1','id'=>'reportName','name'=>'reportName'));?></td>
</tr>
<tr id ="reportForm"></tr>
</table>
</div>
<?php $this->endWidget(); ?>
Regards
Each
(Rikius)
January 26, 2011, 10:55am
2
Hi,
try to make like this.
....
echo CHtml::radioButtonList('reports',$select,$reportType,array('class' =>'select1','name'=>'reportName'));
Yii::app()->clientScript->registerScript('ajax_loading', '
$(".select1").click(function () {
$.ajax({
type:"post",
url: "'. CController::createUrl('reportDetails/getform') .'",
data:{"reports": $(this).val() },
success:function(data) {
$("#reportForm").html(data);
}
});
});
', CClientScript::POS_READY);
Hi,
try to make like this.
....
echo CHtml::radioButtonList('reports',$select,$reportType,array('class' =>'select1','name'=>'reportName'));
Yii::app()->clientScript->registerScript('ajax_loading', '
$(".select1").click(function () {
$.ajax({
type:"post",
url: "'. CController::createUrl('reportDetails/getform') .'",
data:{"reports": $(this).val() },
success:function(data) {
$("#reportForm").html(data);
}
});
});
', CClientScript::POS_READY);
Hiii
Thanks for the reply
but i don’t understand what does this has to do with the radio button not getting selected
Regards
Each
(Rikius)
January 26, 2011, 1:29pm
4
The problem is that in generated javascript source code.
jQuery('body').delegate('#reports_0','click',function(){........ return false;});
return false is not need so because of this, second time selection is not seen in radio buttons.
remistp
(Ead Rspierre)
April 19, 2012, 12:23am
5
Thank you so much, after hours of searching, here’s the solution.
A little tips if someone is in the same case then me.
If you need to submit all the POST parameter from a form
data:jQuery(this).parents("form").serialize(),
tan1540
(Tan1540)
November 12, 2012, 9:42am
6
This can help you
‘ajax’ => array(
‘type’ => ‘POST’, //request type
‘url’ => CController::createUrl(’…/…’),
‘update’ => ‘#…’
‘complete’ => 'function(){
$("#loading-model ").removeClass(“loading”);}’,
),
‘return’=>true, <----Insert this in your code