Answer the question
In order to leave comments, you need to log in
Yii2. How to register css when using pjax?
The question concerns only when working on the yii2 framework.
I'll be as brief as possible with the code. This is the 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'});"]);
}
\yii\widgets\Pjax::end();
\yii\widgets\Pjax::begin(['id' => 'pjax-container']);
if(Yii::$app->request->isPjax) {
$this->registerCssFile('http://test.css'); // не регистрируется...
$this->registerJsFile('http://test.js'); // регистрируется
}
echo \yii\helpers\Html::button('Load Pjax', ['onclick' => "$.pjax.reload({container:'#pjax-container'});"]);
\yii\widgets\Pjax::end();
Answer the question
In order to leave comments, you need to log in
1. Yii::$app->request->isPjax
- it should be in the controller, not in the view.
2. PJAX was not invented to hide blocks. Why is pjax. Do a normal render and use js to show a block with datepiker-om or bootstrap collapse getbootstrap.com/javascript/#collapse
3.
And if I do it without using pjax and call renderAjax in the controller. In this case, everything works fine.- because this is done without using PJAX, do you even understand why it is and how it differs from AJAX?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question