Answer the question
In order to leave comments, you need to log in
How to register all Asset(js files)?
I am receiving a form file with Ajax, and I need to include the files needed for validation. How can i do this. I tried doing $this->registerJs($script) and my script came with ajax! How to include all asset files?
Answer the question
In order to leave comments, you need to log in
In assets/AppAsset.php
<?php
namespace app\assets;
use yii\web\AssetBundle;
class AppAsset extends AssetBundle
{
...
public $js = [
'js/your_file.js'
];
...
}
Use the method to display the form renderAjax
:
public function actionForm()
{
Yii::$app->response->format = Response::FORMAT_JSON;
// ...
return [
'status' => 'success',
'html' => $this->renderAjax('_form', [
// ...
])
];
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question