What is renderAjax (), how is it different from render ()?

When I use regular return this->render('create', ['model' => $model]), my popup crashes. When I turn on return $this->renderAjax('create', ['model' => $model]);, everything becomes magical in their right places. I looked around a bit to read about renderAjax (), but there seems to be absolutely nothing there. Can someone tell me what he is doing? I know ajax, but from what I know, it usually has nothing to do with css or bootstrap.

+7
source share
2 answers

To know the difference between render()and renderAjax(), you first need to understand how it works render().

, render() JS CSS, , , , - beginPage(), head(), beginBody(), endBody() endPage().

, JS , - , :

$this->registerJs("alert()", \yii\web\View::POS_HEAD);

<script type="text/javascript">alert()</script>

, $this->head().

, . ( , beginPage()) JS CSS , jQuery, , - JS .

$this->render() $this->renderPartial() - .

renderAjax() .

, beginPage(), head(), beginBody(), endBody() endPage(). JS , jQuery , AJAX.

+16

render()

.

:

(, "@app/views/site/index"); (, "//site/index"): . . (, "/site/index"): . . (, ""): @/. $context. $context , , , ( ).

renderAjax()

AJAX.

render() , beginPage(), head(), beginBody(), endBody() endPage(). , JS/CSS , .

renderAjax()

()

+1

Source: https://habr.com/ru/post/1673304/


All Articles