Yii 与所选jquery插件相关的dropdownlist。动态更新
我是yii的新手,所以不要太严格。 我有模型中国家/州的相关下拉列表。在选择jquery插件之前,它工作得非常完美。 我用。 所以问题在于如何触发李斯特:更新,以便第二选择可以从标准选择获取数据。 这是创建该列表的视图代码Yii 与所选jquery插件相关的dropdownlist。动态更新,yii,yii-components,Yii,Yii Components,我是yii的新手,所以不要太严格。 我有模型中国家/州的相关下拉列表。在选择jquery插件之前,它工作得非常完美。 我用。 所以问题在于如何触发李斯特:更新,以便第二选择可以从标准选择获取数据。 这是创建该列表的视图代码 if ($field->varname=='country') { echo $form->dropDownList($profile, $field->varname,CHtml::listData(Countries::model()-&
if ($field->varname=='country') {
echo $form->dropDownList($profile, $field->varname,CHtml::listData(Countries::model()->findAll(),'short','title'), array(
'class'=>"chzn-select",
'empty'=>"Select country",
'ajax' => array(
'type' => 'POST',
'url'=>$this->createUrl('registration/state'),
'update' => '#Profile_state',
'data'=>array('country'=>'js:this.value',),
)));
}
elseif($field->varname=='state') {
echo $form->dropDownList($profile, $field->varname,array(), array(
'empty'=>"Select state",
'class'=>"chzn-select",
));
嗯。我找到了解决办法。把它写在这里也许有人会发现它很有用。 在我们的视图文件中
echo $form->dropDownList($profile, $field->varname,CHtml::listData(Countries::model()->findAll(),'short','title'), array(
'class'=>"chzn-select",
'empty'=>"Select country",
'ajax' => array(
'type' => 'POST',
'url'=>$this->createUrl('registration/state'),
'update' => '#Profile_state',
'data'=>array('country'=>'js:this.value',),
'success'=> 'function(data) {
$("#Profile_state").empty();
$("#Profile_state").append(data);
$("#Profile_state").trigger("liszt:updated");
} ',
)));
然后在第二个dropdownlist leve data empty中:
echo $form->dropDownlist($profile, $field->varname, array(),array(
'class'=>"chzn-select",
'empty'=>"Select state",
));
这对我来说非常适合,但给了我几个小时的研究工作。好的。我找到了解决办法。把它写在这里也许有人会发现它很有用。 在我们的视图文件中
echo $form->dropDownList($profile, $field->varname,CHtml::listData(Countries::model()->findAll(),'short','title'), array(
'class'=>"chzn-select",
'empty'=>"Select country",
'ajax' => array(
'type' => 'POST',
'url'=>$this->createUrl('registration/state'),
'update' => '#Profile_state',
'data'=>array('country'=>'js:this.value',),
'success'=> 'function(data) {
$("#Profile_state").empty();
$("#Profile_state").append(data);
$("#Profile_state").trigger("liszt:updated");
} ',
)));
然后在第二个dropdownlist leve data empty中:
echo $form->dropDownlist($profile, $field->varname, array(),array(
'class'=>"chzn-select",
'empty'=>"Select state",
));
这对我来说非常适合,但给了我几个小时的研究工作。你的???在哪里?它不是用于选择的容器。选择state最明显的解决方案,将成功调用添加到ajax'success'=>'function{$Profile_state.triggerlistzt:updated;}'。但是这不起作用。你的???在哪里?它没有为select分配它的容器。选择state最明显的解决方案,将成功调用添加到ajax'success'=>'function{$Profile_state.triggerlistzt:updated;}'。但这不起作用。