There is a site in which there should not be reboots (at least frontend). So, I can not find a solution how to make it so that when I clicked on the menu, the necessary view with the model would be automatically loaded, but there was no page reload.

When trying to use pjax content changes completely, i.e. prapapaet layout and remains the renderPartial view. If it is not clear, then it is different: How to put a menu in the layout (for example, 2 login and signup points) and when you click on one of them, the content changes (the view I needed was displayed).

From searches, I realized that I could put it in a separate block, but I can’t find how

  • This solution, in fact, helped a bit [ stackoverflow.com/questions/23953659/… but I don’t understand the logic (Namely, if specifying id pjax is the same as for the div, the div is updated? Is there a normal connection option? Is it possible to clicking the link 'a' with id = 'a' wrapped in a jacket with id = 'b' display the result in a div with id = 'c' - Oleg Shleif

1 answer 1

Hooray! Finally figured out the same with your question!

<?php Pjax::begin(['id' => 'comments', 'enablePushState' => false, 'linkSelector' => '.btn-custom' ]); ?> <h2>test</h2> <?php Pjax::end(); ?> <?= Html::a("Добавить", ['site/preload'], [ 'class' => 'btn-custom', 'id' => 'refreshButton2' ]) ?> <?= Html::a("Обновить", ['site/reload'], [ 'class' => 'btn-custom', 'id' => 'refreshButton', ]) ?>' 

The bottom line is that you can specify linkSelector and then they will work without restarting the necessary actions. Why do I need this? For navigation, logins, registration and everything else without rebooting) Do not judge strictly, just started learning yii2. Who can fix, clarify or something else - always look and I will consider!