luoxuan 2015-12-18 16:55:47 2721次浏览 1条回复 0 0 0

请问有大神用过select2组件实现省市区的关联查询吗?

  • 回复于 2017-11-30 17:18 举报

    $award =$form->field($award_model, 'award_year')->widget(Select2::classname(), [

                            'data' => $award_model->getAwardList(7615),
                            'language' => 'zh-cn',
                            'options' => ['placeholder' =>$award_year],
                            'pluginOptions' => [
                                'allowClear' => true,
                                'tags' => true,
                            ],
                            'pluginEvents' => [
                                'change' => 'function(){
                                 $.post("'.yii::$app->urlManager->createUrl('video/getaward').'&type=1&parent_award_id="+$(this).val(),function(data){
                                 $("#tag-award_award").html(data);
                                 $("#tag-specific_award").html("<option value=>请选择具体的奖项</option>");
                            })}',
                            ],
                        ]);
                        $award .=$form->field($award_model, 'award_award')->widget(Select2::classname(), [
                            'data' =>$award_model->getAwardList($award_year_id),
                            'language' => 'zh-cn',
                            'options' => ['placeholder' => $award_award],
                            'pluginOptions' => [
                                'allowClear' => true,
                                'tags' => true,
                            ],
                            'pluginEvents' => [
                                'change'=>'function(){
                                $.post("'.yii::$app->urlManager->createUrl('video/getaward').'&type=2&parent_award_id="+$(this).val(),function(data){
                                $("#tag-specific_award").html(data);
                             });}',
                            ],
                        ]);
                        $award .=$form->field($award_model, 'specific_award')->widget(Select2::classname(), [
                            'data' => $award_model->getAwardList($award_award_id),
                            'language' => 'zh-cn',
                            'options' => ['placeholder' => $specific_award],
                            'pluginOptions' => [
                                'allowClear' => true,
                                'tags' => true,
                            ],
                        ]);
                        echo $award;
    
您需要登录后才可以回复。登录 | 立即注册