简体   繁体   English

Visual Studio工具提示设置

[英]Visual Studio Tooltipster setup

I installed Tooltipster using Visual Studio 2015 NuGet Package Manager, closed and opened the project again. 我使用Visual Studio 2015 NuGet软件包管理器安装了Tooltipster,关闭并再次打开了项目。 As expected now there's a new Tooltipster folder under Content. 如预期的那样,在“内容”下有一个新的Tooltipster文件夹。 Following online instructions I just put a 按照在线说明,我只是将

<script>
$(document).ready(function () {
    $('.tooltip').tooltipster();
});

in my razor view 在我的剃刀视图中

and

<link rel="stylesheet" type="text/css" href="tooltipster/dist/css/tooltipster.bundle.min.css" />
<link rel="stylesheet" type="text/css" href="~/Content/Tooltipster/css/themes/tooltipster-light.css" media="screen" />

in _Layout.cshtml 在_Layout.cshtml中

other than already present 除了已经存在

<script src="~/Scripts/jquery-1.12.4.js"></script>

When I add a tooltip to, say, an img, .. the image just disappear (hidden?) 当我向img等添加工具提示时,图像就消失了(隐藏了?)

<img src="/Content/Images/downarrow.png" class="tooltip" title="This is my image's tooltip message!" />

Neither it works this way: 这两种方式都不起作用:

 <span class="fa-lg" title="This is my span's tooltip message!"><a href="#">@Html.FontAwesome(FontAwesomeIconSet.QuestionCircle)</a></span>

Maybe an incompatibility with my jquery version? 也许与我的jQuery版本不兼容? Bootstrap? 引导? What am I doing wrong? 我究竟做错了什么?

I've got ToolTipster working in a Visual Studio ASP.Net MVC application using the version downloaded from their website. 我已经使用从其网站下载的版本在Visual Studio ASP.Net MVC应用程序中使用ToolTipster。

So as a sanity check I can't say much about the NuGet package, but can confirm that ToolTipster works in an ASP.Net MVC 5 web application. 因此,作为健全性检查,我对NuGet软件包的讨论不多,但可以确认ToolTipster是否可以在ASP.Net MVC 5 Web应用程序中使用。

First thing to do is to change the class name on your image from "tooltip" to something else ie "mytooltip". 首先要做的是将图像上的类名称从“工具提示”更改为其他名称,即“ mytooltip”。 The ToolTipster documentation states: ToolTipster文档指出:

"Note: if you use Twitter's Bootstrap, use another class name because 'tooltip' will create a conflict." “注意:如果您使用Twitter的Bootstrap,请使用另一个类名,因为'tooltip'会产生冲突。”

Also change the document ready function to match: 还要更改文档准备功能以使其匹配:

<script>
$(document).ready(function () {
    $('.mytooltip').tooltipster();
});

I'm using jQuery 1.11 so your version 1.12 should be fine. 我正在使用jQuery 1.11,所以您的1.12版本应该没问题。

No issues caused by Bootstrap other than those mentioned above. 除上述问题外,没有其他由Bootstrap引起的问题。

The other thing I don't see in your example is a reference to the ToolTipster js file itself. 在您的示例中我没有看到的另一件事是对ToolTipster js文件本身的引用。

I have the following 我有以下

<script src='/Scripts/ToolTipster/tooltipster.bundle.min.js'></script> 

in my cshtml layout page header. 在我的cshtml布局页面标题中。 Your path to the .js file will differ. .js文件的路径将有所不同。 So perhaps fire it up in a browser and hit the F12 key to load the developer tools, have a look and make sure you have a reference to the tooltipster.bundle.min.js file there. 因此,也许可以在浏览器中启动它并按F12键以加载开发人员工具,看看并确保您对那里的tooltipster.bundle.min.js文件具有引用。

Make sure that when you view the page source, your image class has tooltipstered added after it ie: 确保在查看页面源代码时,图像类之后添加了工具提示 ,即:

class="mytooltip tooltipstered"

This will show that the document load function is correctly modifying your tooltip classes. 这将表明文档加载功能正在正确地修改您的工具提示类。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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