From 5de4aa2054c9a9e5ebd5e7d7706e71cb35534578 Mon Sep 17 00:00:00 2001 From: Loveorigami Date: Wed, 7 Dec 2016 11:11:19 +0300 Subject: [PATCH] modal title from attr --- src/ModalAjax.php | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/src/ModalAjax.php b/src/ModalAjax.php index ae3b328..82cd373 100644 --- a/src/ModalAjax.php +++ b/src/ModalAjax.php @@ -4,6 +4,7 @@ use yii\base\InvalidConfigException; use yii\bootstrap\Modal; +use yii\helpers\Html; use yii\helpers\Url; use yii\web\View; @@ -52,6 +53,24 @@ class ModalAjax extends Modal */ protected $mode = self::MODE_SINGLE; + /** + * Renders the header HTML markup of the modal + * @return string the rendering result + */ + protected function renderHeader() + { + $button = $this->renderCloseButton(); + if ($button !== null) { + $this->header = $button . "\n" . $this->header."\n"; + } + if ($this->header !== null) { + Html::addCssClass($this->headerOptions, ['widget' => 'modal-header']); + return Html::tag('div', "\n" . $this->header . "\n", $this->headerOptions); + } else { + return null; + } + } + /** * @inheritdocs */ @@ -122,9 +141,11 @@ protected function registerMultyModal($id, $view) $(this).attr('data-target', '#$id'); var bs_url = $(this).attr('href'); + var title = $(this).attr('title'); + + if (!title) title = ' '; - //var bs_title = $(this).attr('title'); - //jQuery('#$id').find('.modal-header').html(bs_title); + jQuery('#$id').find('.modal-header span').html(title); jQuery('#$id').kbModalAjax({ url: bs_url,