当前位置: 动力学知识库 > 问答 > 编程问答 >

Does the bootstrap package in meteor include the bootstrap tooltip?

问题描述:

I do meteor add bootstrap in the console, does this add the bootstrap tooltip javascript? If not how do I add it?

网友答案:

Yes the bootstrap plugin includes the tooltip! I use it myself. A thing to note with bootstrap's tooltip is that it cannot run on HTML alone like many of the other features due to performance issues. Each tooltip has to be manually initialized, You can use .tooltip() with jquery on the element you want to tooltip-ify

For instance in your template in your html file

<template name="myTemplate">
    <a href="#" rel="tooltip" title="first tooltip">hover over me</a><br/>
    <a href="#" rel="tooltip" title="second tooltip">hover over me</a><br/>
    <a href="#" rel="tooltip" title="third tooltip">hover over me</a><br/>
</template>

And as use the below in the javascript file to initialize the tooltip

Template.myTemplate.rendered = function() {
   $('a[rel=tooltip]').tooltip() //initialize all tooltips in this template
};

Don't put the <script> tags in your template as would be suggested on various tutorials as meteor handles this in the javascript files

网友答案:

Yes. The entire core bootstrap library is included when you meteor add bootstrap. All the required js and css files will be bundled with your project when you debug or deploy. Once added, you can simply start using the api:

Template.myTemplate.rendered = function() {
   $('#element').tooltip('show')
};

Note, you may want to explore the atmosphere repository for updated bootstrap options, including the bootboxjs and bootstrap-updated projects.

网友答案:

You can see which specific version of Bootstrap is in the package in the Meteor repository on Github:

https://github.com/meteor/meteor/tree/master/packages/bootstrap/js

It does appear to include Bootstrap tooltip.

分享给朋友:
您可能感兴趣的文章:
随机阅读: