I have seen some cjuiautocompleted code like in this post.
What i would like to do is in my first select to use the juiautocompleted widget with a select item, and once i select one of the items returned by autocompleted, i want to load the second select…
<?php
$this->widget('zii.widgets.jui.CJuiAutoComplete', array(
...
'options'=>array(
'delay'=>300,
'minLength'=>2,
'showAnim'=>'fold',
'select'=>"js:function(event, ui) { // how can force to load my second select once i click on one item here...
var terms = split(this.value);
// remove the current input
terms.pop();
// add the selected item
terms.push( ui.item.value );
// add placeholder to get the comma-and-space at the end
terms.push('');
this.value = terms.join(', ');
return false;
}"
),
'htmlOptions'=>array(
'size'=>'40'
),
));?>
</div>
i dont know if i make myself clear explaining my problem
i tried before posting my last post…i does not work…i dont know why…
...
'options'=>array(
'delay'=>300,
'minLength'=>2,
'showAnim'=>'fold',
'select'=>"js:function(event, ui) {
$('#idModeloMueble').val(ui.item.id);
}",
'ajax' => array( // this is tested on my dropdownlist and it works but no for juiautocomplete
'type'=>'POST',
'url'=>CController::createUrl('mueble/cargamedidas'),
'dataType'=>'json',
'data'=>array('idModelo'=>'js:this.value'),
'success'=>'function(data) {
$("#idMedidaMueble").html(data.dropDownMedidas);
$("#idColorFrontal").html(data.dropDownFrontal);
$("#idColorEstructura").html(data.dropDownEstructura);
$("#addCartMueble").css({visibility: "hidden"});
}',
),
),...
and my controller in case youu want to check anything:
public function actionCargamedidas()
{
//Medidas
$muebles = Mueble::model()->findAll('FKModeloMueble=:idModelo', array(':idModelo'=>(int) $_POST['idModelo']));
$medidas = CHtml::listData($muebles,'FKMedidaMueble','medida.concatened');
$dropDownMedidas = "<option value=''>Selecciona Medida...</option>";
foreach($medidas as $value=>$name)
$dropDownMedidas .= CHtml::tag('option', array('value'=>$value),CHtml::encode($name),true);
//Colores Frontal
$frontal = CHtml::listData($muebles,'IdMueble','colorFrontal');
$dropDownFrontal = "<option value='null'>Selecciona Color Frontal...</option>";
foreach($frontal as $value=>$name)
$dropDownFrontal .= CHtml::tag('option', array('value'=>$value),CHtml::encode($name),true);
$dropDownEstructura = "<option value='null'>Selecciona Color Estructura...</option>";
// return data (JSON formatted)
echo CJSON::encode(array(
'dropDownMedidas'=>$dropDownMedidas,
'dropDownFrontal'=>$dropDownFrontal,
'dropDownEstructura'=>$dropDownEstructura,
));
}
$this->widget('zii.widgets.jui.CJuiAutoComplete', array(
//'model'=>$model,
//'attribute'=>'name',
'id'=>'country-chain',
'name'=>'country_chain',
'source'=>$this->createUrl('request/suggestCountry'),
'options'=>array(
'delay'=>300,
'minLength'=>2,
'showAnim'=>'fold',
'select'=>"js:function(event, ui) {
$('#label').val(ui.item.label);//here i would like to load some data from a controller and load my dropdownlists automatically...
$('#code').val(ui.item.code);
$('#call_code').val(ui.item.call_code);
}"
),
'htmlOptions'=>array(
'size'=>'40'
),
));
but, how could i call a controller to get some data and load a dropdownlist??