render('remarks',['model'=>$remarkModel]);"; then create a template pop-up window file, the code is "use yii\help"."/> render('remarks',['model'=>$remarkModel]);"; then create a template pop-up window file, the code is "use yii\help".">

Home >PHP Framework >YII >How to make a pop-up window in Yii

How to make a pop-up window in Yii

藏色散人
藏色散人Original
2020-01-23 21:19:252704browse

How to make a pop-up window in Yii

YII2 Make a pop-up page and modify the content of the pop-up window

Recommendation: "yii tutorial"

template list. The source code of php is as follows

<?php 
echo $this->render(&#39;remarks&#39;,[&#39;model&#39;=>$remarkModel]);
?>
<script type="text/javascript">
    $(document).ready(function(){
        $(".btn_edit").click(function(){
            $.ajax({
                url: "<?=yii::$app->request->baseUrl;?>/usersupervise/remarksuser",
                type: "get",
                data: {openid : &#39;o_-7SspsJjg4e8_dxtSznVGPJ9H4&#39;},
                success: function(data){
                    $(&#39;.showDiv_opaciy, .showDiv_edit&#39;).show();
                }
            });
        });
    });
</script>

Template pop-up tanchuang.php

<?php
    use yii\helpers\Html;
    use yii\widgets\ActiveForm;
?>
<div class="showDiv_edit" style="display:none">
    <div class="showDiv_title"><a href="javascript:void(0);" class="fr close"><img src="<?=yii::$app->request->baseUrl;?>/img/close.gif" width="17" height="16" alt="关闭" /></a>
        <h2>备注用户名</h2>
    </div>
    <div class="showDiv_con"> <span class="fr limit_num">2/30</span>
        <?php $form = ActiveForm::begin(); ?>
        <?= $form->field($model, &#39;remarkname&#39;,[&#39;inputOptions&#39; => [&#39;class&#39; => &#39;inputText inputText_w230 inputText_remarkName&#39;]]) ?>
        <div class="btn_bar">
            <?= Html::submitButton(&#39;确认&#39;, [&#39;class&#39; => &#39;btn btn_primary&#39;]) ?>
            <a href="javascript:void(0);" class="btn btn_default">取消</a>
        </div>
        <?php ActiveForm::end(); ?>
    </div>
</div>

Controller user.php

public function actionRemarksuser()
{
if(yii::$app->request->isAjax){
            if ($model->load(Yii::$app->request->post()) && $model->validate()) {
                print_r($openId[&#39;fromusername&#39;]);//打印不出来,用JS调用实现参数打印
            }
            return $this->renderAjax(&#39;remarks&#39;,[&#39;model&#39;=>$model]);
        }
}

The above is the detailed content of How to make a pop-up window in Yii. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn