简体   繁体   中英

How can i display this bootstrap tooltips dynamically?

I am writing Tooltips that are working fine for static html but for dynamically, its not working.

displayToolTips: function() {
     $(function () {
         $(".tooltipclass").tooltip({
            disabled: true,
            placement : 'bottom'
         }).on("onchange", function () {
             $(this)
                 .tooltip("enable")
                 .tooltip("open");
         }).on("mouseleave", function () {
             $(this)
                 .tooltip("close")
                 .tooltip("disable");
         });

     });
   }

This is the code. and html is :

 <div class="informationIcon tooltipclass margin-tooltip" 
 th:title="#{title.mainimage_title}">i</div>

I write this content in jQuery function that appends dynamically, it is not showing information, when we place the mouse on the tooltip.

Please help, Thanks in advance.

I am sharing The Fiddle here,

http://jsfiddle.net/GrVJc/13/

see displayDynamicRows() in this function, that displays dynamic tooltips which is not showing information.

Bootstrap allows for dynamic info in the tool tip.

As you can see:

<button type="button" class="btn btn-default" data-toggle="tooltip" data-placement="left" title="Tooltip on left">Tooltip on left</button>

Where title= is the information to input. So, either you can do some sort of a loop through whatever you want to play dynamically and put information there, or I'd suggest using jQuery's .attr()

So

<button type="button" class="btn btn-default tool" data-toggle="tooltip" data-placement="left" title="Tooltip on left">Tooltip on left</button> 

$(".tool").attr({title: "WHATEVER})

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