yii2-inline-script Use inline javascripts inside view normally.

shaqman/yii2-inline-script

  1. Installation
  2. Usage

Use inline javascripts inside view normally.

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require --prefer-dist shaqman/yii2-inline-script

or add

"shaqman/yii2-inline-script": "*"

Usage

In your view:

use shaqman\widgets\inlinescript\InlineScript

... view ...

<?php InlineScript::begin([
        'position' => View::POS_HEAD, // yii\web\view\registerJs parameter (optional)
        'key' => 'tmp-script' // yii\web\view\registerJs parameter (optional)
    ]);
?>

<script>

    $("#btn-submit").click(function () {
        alert('hi');
    });

</script>

<?php InlineScript::end(); ?>

... view ...
0 0
1 follower
0 downloads
Yii Version: 2.0
License: MIT
Category: User Interface
Developed by: Blue Spy
Created on: Sep 26, 2017
Last updated: 6 years ago

Related Extensions