|
|
|
@ -71,12 +71,22 @@ class Widget extends \yii\base\Widget
|
|
|
|
|
$view->registerJs($js); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$this->registerClientEvents(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Registers JS event handlers that are listed in [[clientEvents]]. |
|
|
|
|
* @since 2.0.2 |
|
|
|
|
*/ |
|
|
|
|
protected function registerClientEvents() |
|
|
|
|
{ |
|
|
|
|
if (!empty($this->clientEvents)) { |
|
|
|
|
$id = $this->options['id']; |
|
|
|
|
$js = []; |
|
|
|
|
foreach ($this->clientEvents as $event => $handler) { |
|
|
|
|
$js[] = "jQuery('#$id').on('$event', $handler);"; |
|
|
|
|
} |
|
|
|
|
$view->registerJs(implode("\n", $js)); |
|
|
|
|
$this->getView()->registerJs(implode("\n", $js)); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|