YII-Bootstrap - using HTML in Popovers

542 views
Skip to first unread message

Scott Watkins

unread,
Aug 23, 2013, 9:19:34 AM8/23/13
to yii-bo...@googlegroups.com
Hi,

I have a requirement to display HTML in a popover. This is possible in 'core' Bootstrap you simply specify 'html' to be true when creating the event handlers e.g.


jQuery('body').popover({'selector':'a[rel=popover]','html':true});


The problem is I cant see where I can specify this option in yii-bootstrap. The default processing outputs



jQuery('body').popover({'selector':'a[rel=popover]'});


Hence my HTML isn't being rendered in the popover. I've got this to work by editing the core extension files namely the registerPopover() function in
extensions/bootstrap/componentsfunction/Bootstrap.php. It now adds in the HTML=true when rendering the event handler ie.


public function registerPopover($selector = null, $options = array())
{
$this->registerTooltip(); // Popover requires the tooltip plugin
if (!isset($options['selector']))
{
$options['selector'] = $selector !== null ? $selector : 'a[rel=popover]';
$options['html'] = true;
}
$this->registerPlugin(self::PLUGIN_POPOVER, 'body', $options);
}



While this works OK it doesn't feel right editing the extension files! Is there any other way of achieveing the same result? I'm fairly new to YII so any
help would be appreciated

Thanks





 


Scott Watkins

unread,
Aug 23, 2013, 9:47:50 AM8/23/13
to yii-bo...@googlegroups.com
After looking all morning for the solution I find it with 20 minutes of posting this question. To get HTML in PopOvers edit the bootstrap components entry in config/main.php i.e.

'bootstrap'=>array(
    'class'=>'bootstrap.components.Bootstrap',
    'plugins'=>array(
         'popover' => array(
             'options' => array(
                  'html'=>'true'
     )))),


When the event handler is generated it will be thus

jQuery('body').popover({'selector':'a[rel=popover]','html':'true'});

The popover will show its content correctly rendered!. So sit back admire your work, take a moment to feel happy about 
using YII and this excellent extension and continue with your project.


Reply all
Reply to author
Forward
0 new messages