web\View registerJsFile()

registerJsFile() public method

Registers a JS file.

public void registerJsFile ( $url, $options = [], $key = null )
$url string

The JS file to be registered.

$options array

The HTML attributes for the script tag. The following options are specially handled and are not treated as HTML attributes:

  • depends: array, specifies the names of the asset bundles that this JS file depends on.
  • position: specifies where the JS script tag should be inserted in a page. The possible values are:
    • POS_HEAD: in the head section
    • POS_BEGIN: at the beginning of the body section
    • POS_END: at the end of the body section. This is the default value.

Please refer to yii\helpers\Html::jsFile() for other supported options.

$key string

The key that identifies the JS script file. If null, it will use $url as the key. If two JS files are registered with the same key at the same position, the latter will overwrite the former. Note that position option takes precedence, thus files registered with the same key, but different position option will not override each other.

doc_Yii
2016-10-30 17:17:34
Comments
Leave a Comment

Please login to continue.