Class yii\jui\Menu
Inheritance | yii\jui\Menu » yii\widgets\Menu |
---|---|
Available since extension's version | 2.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
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
Method | Description | Defined By |
---|---|---|
init() | Initializes the widget. | yii\jui\Menu |
run() | Renders the widget. | yii\jui\Menu |
Property Details
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").
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").
Method Details
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();
}
}
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));
}
}