how to register a css using pjax

Example. This view code

\yii\widgets\Pjax::begin(['id' => 'pjax-container']);

if(Yii::$app->request->isPjax) {

    echo \yii\jui\DatePicker::widget([

        'name' => 'date',

        'value' => '',


} else {

    echo \yii\helpers\Html::button('Load Pjax', ['onclick' => "$.pjax.reload({container:'#pjax-container'});"]);



The first page load css jquery-ui will not register because the condition does not pass Yii::$app->request->isPjax. I did it on purpose.

When I refresh the page using pyah styles are not loaded. Only js code and files.

If I do this without the use of pjax ( $(’#container’).load(‘url…’) ) and call renderAjax in controller everything works fine.