web\View registerJs()

registerJs() public method

Registers a JS code block.

public void registerJs ( $js, $position = self::POS_READY, $key = null )
$js string

The JS code block to be registered

$position integer

The position at which 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
  • POS_LOAD: enclosed within jQuery(window).load(). Note that by using this position, the method will automatically register the jQuery js file.
  • POS_READY: enclosed within jQuery(document).ready(). This is the default value. Note that by using this position, the method will automatically register the jQuery js file.
$key string

The key that identifies the JS code block. If null, it will use $js as the key. If two JS code blocks are registered with the same key, the latter will overwrite the former.

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

Please login to continue.