Skip to content

Instantly share code, notes, and snippets.

@kdes70
Last active August 14, 2016 16:50
Show Gist options
  • Save kdes70/e7b1fe37da2615f0112e3333af131504 to your computer and use it in GitHub Desktop.
Save kdes70/e7b1fe37da2615f0112e3333af131504 to your computer and use it in GitHub Desktop.
JS блок Yii2
$script = <<< JS
//some script
JS;
//маркер конца строки, обязательно сразу, без пробелов и табуляции
$this->registerJs($script, yii\web\View::POS_READY);
// POS_HEAD
// POS_BEGIN: после тэга <body>
// POS_END: перед тэгом </body>
// POS_LOAD: оборачивается в jQuery(window).load(). Note that by using this position, the method will automatically register the jQuery js file.
// POS_READY: оборачивается вjQuery(document).ready(). This is the default value. Note that by using this position, the method will automatically register the jQuery js file.
$this->registerJsFile('url/to/file.js', ['position' => yii\web\View::POS_END]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment