shaqman/yii2-inline-script

Use inline javascripts inside view normally.

Installs: 486

Dependents: 0

Suggesters: 0

Security: 0

Stars: 2

Watchers: 2

Forks: 1

Open Issues: 0

Type:yii2-extension

pkg:composer/shaqman/yii2-inline-script

1.0.1 2017-09-26 10:10 UTC

This package is auto-updated.

Last update: 2025-10-05 21:27:45 UTC


README

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 ...