title: How to update widget with pjax in modal window in yii2
body: <p>I have two ActiveForms in a modal window and after submitting first form, I need to update second one and stay in modal.</p>
  <p><img src="https://i.stack.imgur.com/Ez3NW.png" alt="modal" /></p>
  <p>As I understand pjax can handle that, but can't get it to work properly.</p>
  <p>In _form.php I have ActiveForm with widget which should be updated:</p>
  <pre class="lang-php prettyprint-override"><code>&lt;?php $form = ActiveForm::begin([
      'id'=&gt;'form',
      'enableAjaxValidation'=&gt;true,
  ]); ?&gt;
  &lt;?= Html::activeHiddenInput($riskModel, 'id', ['value' =&gt; $riskModel-&gt;id]) ?&gt;
  
  &lt;?php Pjax::begin([
      'id' =&gt; 'solutionItems',
  ]) ?&gt;
  //need to update this widget
      &lt;?= $form-&gt;field($riskModel, 'solutions_order')-&gt;widget(SortableInput::classname(), [
          'items' =&gt; $riskModel-&gt;getSolutionList(),
          'hideInput' =&gt; false,
          'options' =&gt; ['class'=&gt;'form-control', 'readonly'=&gt;false]
      ]); ?&gt;
  &lt;?php Pjax::end() ?&gt;
  
  &lt;div class=&quot;form-group&quot;&gt;
      &lt;?= Html::submitButton($riskModel-&gt;isNewRecord ? 'Create' : 'Update', ['class' =&gt; $riskModel-&gt;isNewRecord ? 'btn btn-success' : 'btn btn-primary', 'onclick' =&gt; 'return isConnected()']) ?&gt;
  &lt;/div&gt;
  
  &lt;?php ActiveForm::end(); ?&gt;
  </code></pre>
  <p>And then I have Ajax request which returns success if new solution is created:</p>
  <pre class="lang-js prettyprint-override"><code>$.ajax({
      url: form.attr('action'),
      type: 'post',
      data: form.serialize(),
      success: function (data) {
          if (data &amp;&amp; data.result == 1) {
              $.pjax.reload({container:'#solutionItems'});
          }
      },
      error: function (XMLHttpRequest, textStatus, errorThrown) {
          $(&quot;#error&quot;).html(&quot;Kļūda! Neizdevās pievienot ierakstu.&quot;).fadeIn('highlight','', 2000, callbackError());
          $(&quot;#solutions-solution&quot;).val(&quot;&quot;);
      }
  });
  </code></pre>
  <p>But</p>
  <pre class="lang-js prettyprint-override"><code>$.pjax.reload({container:'#solutionItems'});
  </code></pre>
  <p>closes the modal.
  If I put the returned value in a div, then ajax works properly and the modal is not closing.</p>