简体   繁体   English

单击图像按钮时工具提示保持可见

[英]Tooltip stays visible on click of imagebutton

I have an ImageButton with a tooltip. 我有一个带有工具提示的ImageButton。 On clicking the button, the tooltip stays visible and sticks to the mouse on the page. 单击按钮后,工具提示将保持可见状态,并停留在页面上的鼠标上。 I want the tooltip to disappear once the button has been clicked but can't find a way to do this. 我希望工具提示在单击按钮后消失,但是找不到解决方法。

Any advice would be appreciated! 任何意见,将不胜感激! markup: 标记:

<asp:TemplateField HeaderText="Mark as Read">
    <ItemTemplate>
        <asp:ImageButton ID="img_markAsRead" runat="server" ImageUrl="img/icons/eye.png" CssClass="tooltip" Width="20"  ToolTip="Mark this Notification as Read" CommandName="Edit" CommandArgument='<%# Eval("notification_id")%>'/>
    </ItemTemplate>
</asp:TemplateField>

CSS : CSS:

.ui-tooltip {
    padding: 8px;
    position: absolute;
    z-index: 9999;
    max-width: 300px;
    -webkit-box-shadow: 0 0 5px #aaa;
    box-shadow: 0 0 5px #aaa;
}

Code behind : 后面的代码:

protected void grdv_RowEditing(object sender, GridViewEditEventArgs e)
{
    GridViewRow theRow = grdv_notifications.Rows[e.NewEditIndex];
    ImageButton theButton = (ImageButton)theRow.FindControl("img_markAsRead");
    string notificationNo = theButton.CommandArgument;

    #region the clever sql statement to do the updates

    #endregion

    //reload the gridview
    loadGridview();

    //set the notification number       
    MasterPage master = (MasterPage)this.Master;
    master.updateNotificationCount(grdv_notifications.Rows.Count);
}

Based on your jQuery tag and the fact that the class name is "ui-tooltip", I'm guessing that you're using jQuery UI tooltip. 基于您的jQuery标记和类名是“ ui-tooltip”的事实,我猜您正在使用jQuery UI工具提示。 In which case, one of the options is "track", which you can set to false when you initialise... 在这种情况下,选项之一是“跟踪”,您可以在初始化时将其设置为false

$( document ).tooltip({
  track: false
});

This should be false by default though, so you must be setting it to true . 不过,默认情况下,它应该为false ,因此必须将其设置为true

After racking my brain, the answer was simple. 绞尽脑汁后,答案很简单。

Adding a Response.Redirect("notifications.aspx"); 添加Response.Redirect("notifications.aspx");

to reload the page after clicking on the ImageButton reloaded the page and cleared out the tooltip. 单击ImageButton后重新加载页面,重新加载页面并清除工具提示。 Simple, but effective! 简单但有效!

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

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