Css – Yii 2.0 Loading css and js in renderPartial

csstwitter-bootstrapyii2

How can I load css and javascript files if I render a page using renderPartial() ?
The problem is that I NEED my page to be mobile responsive. This does not seem to be a problem when I use render()

I tried including the boostrap css and js in my page, but It still did not work.

I have included the css and js in my page :

<link rel="stylesheet" href="<?= Yii::getAlias('@web/css/bootstrap.min.css')?> ">
<link rel="stylesheet" href="<?= Yii::getAlias('@web/css/sb-admin.css')?>">
<link rel="stylesheet" href="<?= Yii::getAlias('@web/css/site.css')?>">
<link rel="stylesheet" href="<?= Yii::getAlias('@web/css/jquery-ui.css')?>">

And

<script type="text/javascript" src="<?= Yii::getAlias('@web/js/jquery.js')?>"></script>
<script type="text/javascript" src="<?= Yii::getAlias('@web/js/bootstrap.min.js')?>"></script>

And in my controller :

return $this->renderPartial('create', [
                        'model' => $model,
            ]);

What Am I missing ?

Best Solution

You are looking for \yii\web\view::renderAjax() :) This does include javascript and css, but does not include the layout (and thus acts as a partial render).