River
River

Reputation: 1487

bootstrap popover content setting

bootstrap popover currrently expects this:

<a href="#" id="example" class="btn btn-danger"  rel="popover" data-content="It's so simple to create a tooltop for my website!" data-original-title="Twitter Bootstrap Popover">hover for popover</a>  

$("#example").popover({placement:'bottom'});

..expects you to define data-content in template or dynamically pass it in jquery.

Is there anyway it can support format like below:

..the point being able to define content/title in blocks

<div id="example">
<div class="original-title">
Twitter Bootstrap Popover
</div>
<div class="data-content">
It's so simple to create a tooltop for my website!
</div>
<a>hover for popover</a>
<div>

$("#example").popover({placement:'bottom'})

Upvotes: 3

Views: 7331

Answers (2)

Dav
Dav

Reputation: 330

I think that can be possible using a javascript code to give the content of this divs to the elements but is not recommended.

$("a").attr("data-title",$(".data-title").html()).attr(".data-content",$(".data-content").html());
$('a').popover({placement:'bottom'})

Upvotes: 1

Andres I Perez
Andres I Perez

Reputation: 75379

Currently, no, since the popover script is basically extending the functionally of the tooltip script, but nothing is impossible. You can modify the script and add custom data-attributes to support your markup yourself, but then when updates come around you will have to do it again if you want to support your edits, or not update at all.

Upvotes: 1

Related Questions