YII2 做弹窗页面然后修改弹窗的内容
推荐:《yii教程》
模板list.php的源码如下
<?php echo $this->render('remarks',['model'=>$remarkModel]); ?> <script type="text/javascript"> $(document).ready(function(){ $(".btn_edit").click(function(){ $.ajax({ url: "<?=yii::$app->request->baseUrl;?>/usersupervise/remarksuser", type: "get", data: {openid : 'o_-7SspsJjg4e8_dxtSznVGPJ9H4'}, success: function(data){ $('.showDiv_opaciy, .showDiv_edit').show(); } }); }); }); </script>
模板弹窗 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, 'remarkname',['inputOptions' => ['class' => 'inputText inputText_w230 inputText_remarkName']]) ?> <div class="btn_bar"> <?= Html::submitButton('确认', ['class' => 'btn btn_primary']) ?> <a href="javascript:void(0);" class="btn btn_default">取消</a> </div> <?php ActiveForm::end(); ?> </div> </div>
控制器 user.php
public function actionRemarksuser() { if(yii::$app->request->isAjax){ if ($model->load(Yii::$app->request->post()) && $model->validate()) { print_r($openId['fromusername']);//打印不出来,用JS调用实现参数打印 } return $this->renderAjax('remarks',['model'=>$model]); } }
以上是yii如何做弹窗的详细内容。更多信息请关注PHP中文网其他相关文章!