Yii2 - How We can Change the element that Will be update via Pjax response -


how can change element(tag) update via server response .

this form

<div  id="test" class="modal fade bs-example-modal-sm" tabindex="-1" role="dialog" aria-labelledby="mysmallmodallabel">           <div class="modal-dialog modal-sm">             <div class="modal-content">                 <div class="modal-header">ورود به سایت</div>                 <?php                 \yii\widgets\pjax::begin(['enablepushstate'=>false]);                 $loginmodel=new \common\models\loginform();                 $form=\yii\bootstrap\activeform::begin([                     'id'=>'form-login',                                             'options'=>['data-pjax'=>''],                     'method'=>'post',                     'action'=>['site/login'],                  ]);                  echo $form->field($loginmodel, 'username')->textinput()->label('نام کاربری');                 echo $form->field($loginmodel, 'password')->passwordinput()->label('رمز عبور');                 echo $form->field($loginmodel,'captchalogin')->widget(yii\captcha\captcha::classname(),[                     'attribute'=>'captchalogin',                     'captchaaction'=>'site/captchalogin',                     'id'=>'captchalogin',                                                             ])->label('کد امنیتی');                                                         ?>                 <div style="color:#999;margin:1em 0">                                   برای یادآوری رمز عبور <?= \yii\helpers\html::a('اینجا کلیک کنید', ['site/request-password-reset']) ?>.                 </div>                 <div class="form-group">                     <?= \yii\helpers\html::submitbutton('ورود', ['class' => 'btn btn-primary', 'name' => 'login','value'=>'ورود']) ?>                 </div>                 <div id="my"></div>                  <?php                  \yii\bootstrap\activeform::end();                  \yii\widgets\pjax::end();                 ?>             </div>           </div>         </div> 

basically of <div id=#test></div> content updates new contents . want push responses <div id="my"></div> tag , no update anothers.

you may use pjax:beforereplace method , push contents in <div id="my"></div> instead of <div id=#test></div>.

here documentation link.

for ex.

$(function(){ $('#test').on('pjax:beforereplace',function(contents, options){ $('#my').html(contents); }); });

your js code may this.


Comments

Popular posts from this blog

Hatching array of circles in AutoCAD using c# -

ios - UITEXTFIELD InputView Uipicker not working in swift -