javascript - Print js file Yii2 -


is there way print js file? know can use register method of assetbundle class register js/css file page, there option: store javascript code in php variable , use following method:

\yii\web\view::registerjs($js, \yii\web\view::pos_ready);

but need (on server-side) open js file, contents , write down code html.

the meaning of doing javascript code needed in 1 page, don't want add requests on client-side.

also, know, can use php include method load file , store variable, maybe there yii-way.

so, there proper way ? appreciated.

try , hope you.

<?php   $this->registerjs('  $(document).ready(function(){  $(\'.ordinary\').hide();   $(\'.special\').hide();  $(\'#company-typeofcompany\').change(function () {      var x = $(this).val();      if (x === "ordinary") {          $(\'.ordinary\').show();            $(\'.special\').hide();      } else {          $(\'.special\').show();          $(\'.ordinary\').hide();       }  });    });', \yii\web\view::pos_ready);    ?> 

thank you..


Comments

Popular posts from this blog

Email notification in google apps script -

c++ - Difference between pre and post decrement in recursive function argument -

javascript - IE11 incompatibility with jQuery's 'readonly'? -