如何在服务器端的数据库中设置jquery工具提示? [英] How do I set a jquery tooltip from a database on server side?

查看:97
本文介绍了如何在服务器端的数据库中设置jquery工具提示?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的asp.net页面上有一个标签,看起来像这样:

I have a label on my asp.net page, it looks like this:

更多信息

当我将鼠标悬停在它上面时,我希望显示这些jquery工具提示之一.数据将来自我后面的代码中的数据库.我看过qtip,jquery工具和telerik工具提示.我只是不确定如何从服务器端设置工具提示的内容.

When I hover over it, I'd like one of those jquery tooltips to display. The data will come from a database from my code behind. I've look at qtip, jquery tools, and the telerik tooltip. I'm just not sure how to set the content of the tooltip from server side.

推荐答案

使用工具提示插件的最简单实现( http://docs.jquery.com/Plugins/Tooltip )将是:

The simplest implementation using tooltip plugin (http://docs.jquery.com/Plugins/Tooltip) will be just:

$("a").tooltip();

上面使用title作为默认的工具提示内容.

The above use title as the default tooltip content.

假设您要按顺序使用X个自定义内容来提示X个项目,这是一种方法

Suppose you have X items to be tooltipped with X custom content in a sequence, here's one way

在您的代码隐藏中,如下所示插入工具提示:

In your code-behind, string up the tooltips like this:

protected string tooltips;
//perform your data retrieval and create a string like this:
tooltips = "'tip1','tip2','tip3'";

在您的javascript中,将工具提示字符串数组分配给javascript数组:

In your javascript, to assign the tooltip string array to a javascript array:

var myToolTips = new Array(<%=mytooltips%>);

然后使用JQuery的each()遍历项目:

Then iterate through the items using JQuery's each():

$(".someclass a").each(function(i){
    $(this).tooltip({
       showBody: myToolTips[i];
    });
})

这篇关于如何在服务器端的数据库中设置jquery工具提示?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆