Yii 1.1.3 setting selected value of dependent dropdown 2
I previously created a question where I was wondering how to set the selected value for a dependent dropdown. It was easy, the person advised me to set the second parameter.
echo CHtml::dropDownList('OpenLessons[Building]', $buildingClassID, $buildingList,array(
'ajax' => array(
'type'=>'POST',
'url'=>CController::createUrl('ajax/floorList'),
'update'=>'#OpenLessons_Floor',
)));
echo CHtml::dropDownList('OpenLessons[Floor]',$model->Class_ID, array(),array(
'ajax' => array(
'type'=>'POST', //request type
'url'=>CController::createUrl('ajax/roomList'),
'update'=>'#OpenLessons_Class_ID',
)));
echo CHtml::dropDownList('OpenLessons[Class_ID]',$model->Class_ID, array());
where $buildingClassId
is the value of select. So that works great for the first choice. But how can I set the same for dependencies? When I look at this code, it looks like this:
<select name="OpenLessons[Floor]" id="OpenLessons_Floor">
</select>
I expected it to have some parameters because I am setting the default for the first one. Therefore, even if I put some value as the second parameter of seconddropdown, it will not be selected. Any tips / suggestions?
UPDATE . I would mention that I don't see the floorlist XHR console call. How can i do this?
UPDATE
$(document).ready(function()
{
$('#OpenLessons_Building').trigger('change');
$('#OpenLessons_Building option').trigger('click');
}).on('change','#OpenLessons_Building',function()
{
console.log('changed');
}).on('click','#OpenLessons_Building option',function()
{
console.log('clicked');
});
I tried it like this. Both the change and the click occurred because I can see the output in the console, but the dependent arrays are still empty.
source to share