Class yii\jui\Dialog
Inheritance | yii\jui\Dialog » yii\jui\Widget » yii\base\Widget |
---|---|
Available since extension's version | 2.0 |
Source Code | https://github.com/yiisoft/yii2-jui/blob/master/Dialog.php |
Dialog renders an dialog jQuery UI widget.
For example:
Dialog::begin([
'clientOptions' => [
'modal' => true,
],
]);
echo 'Dialog contents here...';
Dialog::end();
See also http://api.jqueryui.com/dialog/.
Public Properties
Property | Type | Description | Defined By |
---|---|---|---|
$clientEventMap | array | Event names mapped to what should be specified in .on() . |
yii\jui\Widget |
$clientEvents | array | The event handlers for the underlying jQuery UI widget. | yii\jui\Widget |
$clientOptions | array | The options for the underlying jQuery UI widget. | yii\jui\Widget |
$options | array | The HTML attributes for the widget container tag. | yii\jui\Widget |
Public Methods
Method | Description | Defined By |
---|---|---|
init() | Initializes the widget. | yii\jui\Dialog |
run() | Renders the widget. | yii\jui\Dialog |
Protected Methods
Method | Description | Defined By |
---|---|---|
registerClientEvents() | Registers a specific jQuery UI widget events | yii\jui\Widget |
registerClientOptions() | Registers a specific jQuery UI widget options | yii\jui\Widget |
registerWidget() | Registers a specific jQuery UI widget asset bundle, initializes it with client options and registers related events | yii\jui\Widget |
Method Details
Initializes the widget.
public void init ( ) |
public function init()
{
parent::init();
echo Html::beginTag('div', $this->options) . "\n";
//Fix for closing icon (x) not showing up in dialog
$this->getView()->registerJs("
if ($.fn.button) {
var bootstrapButton = $.fn.button.noConflict();
$.fn.bootstrapBtn = bootstrapButton;
}",
\yii\web\View::POS_READY
);
}
Defined in: yii\jui\Widget::registerClientEvents()
Registers a specific jQuery UI widget events
protected void registerClientEvents ( $name, $id ) | ||
$name | string |
The name of the jQuery UI widget |
$id | string |
The ID of the widget |
protected function registerClientEvents($name, $id)
{
if (!empty($this->clientEvents)) {
$js = [];
foreach ($this->clientEvents as $event => $handler) {
if (isset($this->clientEventMap[$event])) {
$eventName = $this->clientEventMap[$event];
} else {
$eventName = strtolower($name . $event);
}
$js[] = "jQuery('#$id').on('$eventName', $handler);";
}
$this->getView()->registerJs(implode("\n", $js));
}
}
Defined in: yii\jui\Widget::registerClientOptions()
Registers a specific jQuery UI widget options
protected void registerClientOptions ( $name, $id ) | ||
$name | string |
The name of the jQuery UI widget |
$id | string |
The ID of the widget |
protected function registerClientOptions($name, $id)
{
if ($this->clientOptions !== false) {
$options = empty($this->clientOptions) ? '' : Json::htmlEncode($this->clientOptions);
$js = "jQuery('#$id').$name($options);";
$this->getView()->registerJs($js);
}
}
Defined in: yii\jui\Widget::registerWidget()
Registers a specific jQuery UI widget asset bundle, initializes it with client options and registers related events
protected void registerWidget ( $name, $id = null ) | ||
$name | string |
The name of the jQuery UI widget |
$id | string |
The ID of the widget. If null, it will use the |
protected function registerWidget($name, $id = null)
{
if ($id === null) {
$id = $this->options['id'];
}
JuiAsset::register($this->getView());
$this->registerClientEvents($name, $id);
$this->registerClientOptions($name, $id);
}
Renders the widget.
public void run ( ) |
public function run()
{
echo Html::endTag('div') . "\n";
$this->registerWidget('dialog');
}