Pjax not working with dynamic elements

Title says it all.

I have a simple partial view that gets injected to a page via AJAX. The partial view though, has a Pjax container that doesn’t fire properly when dynamically created. I need it to send a POST request, but it is sending a GET request when it was dynamically created.

If I reload the page and the partial view is rendered with the page, it works as intended (sends POST request). Issue only arises when the partial view is injected dynamically.

What do I need to do to make it fire as POST each time?

Seems to be the clientOptions are ignored when dynamically created.

Here’s the code:


public function actionNewLine($key) 


        if (Yii::$app->request->isAjax && Yii::$app->request->isPost) {

            $nline = new StoLineVote($key);


            $save = $nline->svLine(Yii::$app->request->post());


            if (is_array($save)) {                

                return $this->renderAjax('_userNewLine', ['line' => $save, 'key' => $key]);


            } else {

                return $this->renderAjax('_newLine', ['model' => $save, 'key' => $key]);




The partial view _userNewLine.php

<div class="sto-pub-line">

    <?php Pjax::begin(['enablePushState' => false, 'clientOptions' => ['type' => 'POST']]) ?>

    <span class="line"> <?= $line['line'] ?> </span>

    <span class="username"> <?= Html::a($line['username'],['profile/profile', 'user' => $line['username']]) ?> </span>




    <?= Html::a('edit', ['edit-oline', 'key' => $key]) ?>


    <?= Html::a('delete', ['del-oline', 'key' => $key]) ?>


    <?php Pjax::end() ?>



If the delete link is clicked without a POST header, nothing happens.

Any and all help would be appreciated.


So no one knows how to resolve this?