i can create a dependent dropdownlist, but with similiar ajax script i can not create a dependent EJuiComboBox. can somebody tell me what went wrong in my code? script below is my progress so far.
by the way, the “'url’=>CController::createUrl(‘tx/serviceWork/GetVehicleByCustomer’)” is working fine, becouse i already test with dropdownlist.
controller : serviceWork
<?php
public function actionGetVehicleByCustomer() {
$data = Vehicle::model()->findAll('customer_id=:customer_id',
array(':customer_id' => (int) $_POST['customer_id']));
$data = CHtml::listData($data, 'vehicle_id', 'police_number');
foreach ($data as $value => $name) {
echo CHtml::tag('option', array('value' => $value), CHtml::encode($name), true);
}
}
?>
view : _form.php
<?php
echo '<label class="control-label" for="customer_id">Customer</label> </br>';
$this->widget('ext.combobox.EJuiComboBox', array(
'model' => $model,
'attribute' => 'customer_id',
'data' => CHtml::listData(Customer::model()->findAll(), 'customer_id', 'customer_name'),
'options' => array(
'onSelect' => CHtml::ajax(array(
'type'=>'POST',
'url'=>CController::createUrl('tx/serviceWork/GetVehicleByCustomer'),
'update'=>'#ServiceWork_vehicle_id',
'data'=>array('customer_id'=>'js:this.value'),
)),
'allowText' => true,
),
'htmlOptions' => array('style'=> 'float:left;width:90%;'),
));
?>
before i select customer, this [size="2"]EJuiComboBox below still contain its own data. but after i select customer, this EJuiComboBox data is all gone. so, i think the ajax is working, but i miss something probably.[/size]
<?php
echo '<label class="control-label" for="vehicle_id">Vehicle</label> </br>';
$this->widget('ext.combobox.EJuiComboBox', array(
'model' => $model,
'attribute' => 'vehicle_id',
'data' => CHtml::listData(Vehicle::model()->findAll(), 'vehicle_id', 'police_number'),
'options' => array(
'allowText' => true,
),
'htmlOptions' => array('style'=> 'float:left;width:90px;'),
));
?>
thank you.