protected function registerPlugin($name, $selector = null)
    {
        /** @var View $view */
        $view = $this->getView();

        MaterializePluginAsset::register($view);

        $id = $this->options['id'];

        if (is_null($selector)) {
            $selector = '#' . $id;
        }

        if ($this->clientOptions !== false) {
            $options = empty($this->clientOptions) ? '{}' : Json::htmlEncode($this->clientOptions);

            $js = "document.addEventListener('DOMContentLoaded', function() {M.$name.init(document.querySelectorAll('$selector'), $options);});";
            $view->registerJs($js, View::POS_END);
        }

        $this->registerClientEvents();
    }
protected function registerPlugin($name, $selector = null)
    {
        /** @var View $view */
        $view = $this->getView();

        MaterializePluginAsset::register($view);

        $id = $this->options['id'];

        if (is_null($selector)) {
            $selector = '#' . $id;
        }

        if ($this->clientOptions !== false) {
            $options = empty($this->clientOptions) ? '{}' : Json::htmlEncode($this->clientOptions);

            $js = "document.addEventListener('DOMContentLoaded', function() {M.$name.init(document.querySelectorAll('$selector'), $options);});";
            $view->registerJs($js, View::POS_END);
        }

        $this->registerClientEvents();
    }
protected function registerPlugin ( $ name , $ selector = null ) { /** @var View $view */ $ view = $ this -> getView ( ) ; MaterializePluginAsset :: register ( $ view ) ; $ id = $ this -> options [ 'id' ] ; if ( is_null ( $ selector ) ) { $ selector = '#' . $ id ; } if ( $ this -> clientOptions !== false ) { $ options = empty ( $ this -> clientOptions ) ? '{}' : Json :: htmlEncode ( $ this -> clientOptions ) ; $ js = "document.addEventListener('DOMContentLoaded', function() {M.$name.init(document.querySelectorAll('$selector'), $options);});" ; $ view -> registerJs ( $ js , View :: POS_END ) ; } $ this -> registerClientEvents ( ) ; }
Registers a specific Materialize plugin and the related events.
@param string $name the name of the Materialize plugin
@param string|null $selector the name of the selector the plugin shall be attached to
@uses [yii\helper\BaseJson::encode()](http://www.yiiframework.com/doc-2.0/yii-helpers-basejson.html#encode()-detail)
to encode the [[clientOptions]]
@uses [[MaterializePluginAsset::register()]]
@uses [[registerClientEvents()]]
Registers a specific Materialize plugin and the related events .