简体   繁体   中英

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'})

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'})

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM