Class yii\jui\Menu

Inheritanceyii\jui\Menu » yii\widgets\Menu
Available since extension's version2.0
Source Code https://github.com/yiisoft/yii2-jui/blob/master/Menu.php

Menu renders a menu jQuery UI widget.

See also http://api.jqueryui.com/menu/.

Public Properties

Hide inherited properties

Property Type Description Defined By
$clientEvents array The event handlers for the underlying jQuery UI widget. yii\jui\Menu
$clientOptions array The options for the underlying jQuery UI widget. yii\jui\Menu

Public Methods

Hide inherited methods

Method Description Defined By
init() Initializes the widget. yii\jui\Menu
run() Renders the widget. yii\jui\Menu

Property Details

Hide inherited properties

$clientEvents public property

The event handlers for the underlying jQuery UI widget. Please refer to the corresponding jQuery UI widget Web page for possible events. For example, this page shows how to use the "Accordion" widget and the supported events (e.g. "create").

public array $clientEvents = []
$clientOptions public property

The options for the underlying jQuery UI widget. Please refer to the corresponding jQuery UI widget Web page for possible options. For example, this page shows how to use the "Accordion" widget and the supported options (e.g. "header").

public array $clientOptions = []

Method Details

Hide inherited methods

init() public method

Initializes the widget.

If you override this method, make sure you call the parent implementation first.

public void init ( )

                public function init()
{
    parent::init();
    if (!isset($this->options['id'])) {
        $this->options['id'] = $this->getId();
    }
}

            
run() public method

Renders the widget.

public void run ( )

                public function run()
{
    parent::run();
    $view = $this->getView();
    JuiAsset::register($view);
    $id = $this->options['id'];
    if ($this->clientOptions !== false) {
        $options = empty($this->clientOptions) ? '' : Json::htmlEncode($this->clientOptions);
        $js = "jQuery('#$id').menu($options);";
        $view->registerJs($js);
    }
    if (!empty($this->clientEvents)) {
        $js = [];
        foreach ($this->clientEvents as $event => $handler) {
            $js[] = "jQuery('#$id').on('menu$event', $handler);";
        }
        $view->registerJs(implode("\n", $js));
    }
}