goose
goose

Reputation: 2652

Yii Booster popover over text rather than button

Yii booster documentation shows how to make a popover over a button. I want to create one over an anchor element rather than a button. Essentially I want to combine the popover with Yii's tooltip. Does anyone know how to do this?

This is the code for the pop-over:

$this->widget(
'bootstrap.widgets.TbButton',
array(
    'label' => 'Top popover',
    'type' => 'primary',
    'htmlOptions' => array(
        'data-title' => 'A Title',
        'data-placement' => 'top',
        'data-content' => "And here's some amazing content. It's very engaging. right?",
        'data-toggle' => 'popover'
    ),
));

If there was a way of altering this to not render a button, but just an anchor the problem would be solved, but I can't find anything in the code that I can use to do this.

Update

Following Sergey's answer, here's what I've put:

echo CHtml::Link("$detail->text", null, 
array(
'rel' => 'popover',
'data-trigger' => "hover",
'data-title' => "$header",
'data-content' => "$body"
));

This is close to what I need, but for some reason the hove doesn't work, only the click and also only the content get's displayed not the title.

Upvotes: 2

Views: 3080

Answers (1)

Sergey  Bulavkin
Sergey Bulavkin

Reputation: 2405

You can use CHtml:

<?php echo CHtml::Link('<i class="icon-info-sign"></i>', null, [
    'rel' => 'popover',
    'data-trigger' => 'hover',
    'data-title' => 'Your title',
    'data-content' => 'Your content',
])?>

enter image description here

Update: For Bootstrap 2.3.2 :

<?php Yii::app()->clientScript->registerScript("", "$('.ipopover').popover();", CClientScript::POS_READY) ?>
<?php echo CHtml::Link('<i class="icon-info-sign"></i>', null, array(
    'class' => 'ipopover',
    'data-trigger' => 'hover',
    'data-title' => 'Your title',
    'data-content' => 'Your content',
))?>

Upvotes: 5

Related Questions