I have a setup something like this:
<?php
$form=$this->beginWidget('CActiveForm', array('id'=>'my-form', 'enableAjaxValidation'=>false,)); ?>
$this->widget('zii.widgets.jui.CJuiTabs', array(
'tabs'=>array(
'Properties'=>array('ajax'=>$this->createUrl('/myController/properties')),
'Names'=>array('ajax'=>$this->createUrl('/myController/names')),
),
'options'=>array(
'collapsible'=>false,
),
)); ?>
<?php
Yii::app()->clientScript->registerScript('search',
"$('#MyModelProperties_country_id').change(function(){alert($('#MyModelProperties_country_id').val())});");
?>
<?php $this->endWidget(); ?>
In myController/properties I have
public function actionProperties{
$model = new MyModel;
$this->renderPartial('_properties', array('model'=>$model,));
}
And in _properties.php
<?php echo CHtml::dropDownList('MyModelProperties[country_id]', '', $countrySelect, array('empty'=>'(Select country)', )); ?>
Originally, I wanted to write a dependent dropdown, but the first one never submitted a server request, so I tried to simplify my code as much as possible to catch the error. I could not.
A couple of things to note: I tried to put the
Yii::app()->clientScript->registerScript('')
inside the CJuiTabs, before the CJuiTabs or after the CJuiTabs, it did not matter; however, if I put the whole select outside the CJuiTabs my JS script works just fine. I also tried to write the script inside plain
<script type="text/javascript"></script>
tags, but the behavior was similar. It’s also worth noting, that if I view the source of the displayed page in my browser, the JS is there, it just doesn’t work if the select is inside the CJuiTab.
Is this some kind of bug, or am I missing something? Please advise!