php - How can registerJs work with beforaction() in yii2 -
i created module .then in side module before action calling registerjs not working.
public function beforeaction($action){ $js=yii::getalias('@webroot/assets_app/js/login.js'); $this->getview()->registerjs($js, \yii\base\view::pos_end); }
its showing undefined class constant 'pos_end'
it's in web
namespace
\yii\web\view::pos_end
edit
just noticed, if want register js file need utilize registerjsfile. default position pos_end
so need is,
public function beforeaction($action){ $js = yii::getalias('@webroot/assets_app/js/login.js'); $this->getview()->registerjsfile($js); }
php yii2
No comments:
Post a Comment