当不同目标的不同事件被触发时显示单个qtip?

发布于 2024-10-09 02:47:08 字数 1083 浏览 1 评论 0原文

我的表单中几乎没有输入和选择控件,每个控件前面都有一个小问号图标,当鼠标悬停在该 gif 上时,在出色的 jquery jquery.qtip-1.0.0-rc3 的帮助下,该图标将显示工具提示.js(带有 jquery-1.3.2.min.js)插件如下:

   $('#questionmark1').qtip({
        content: 'sample help content'
        , style: { name: 'sampleStyle' }
        , position: { corner: { target: 'bottomLeft', tooltip: 'rightTop'} }         
    });

我还想在相应的输入字段获得焦点时显示工具提示,并在模糊时隐藏。下面的代码可以解决这个问题,但当鼠标悬停在该 gif 上时,不会显示工具提示,

  $('#questionmark1').qtip({
        content: 'sample help content'
        , style: { name: 'sampleStyle' }
        , position: { corner: { target: 'bottomLeft', tooltip: 'rightTop'} }         
         , show: { when: { target: $('#input1'), event: 'focus'} }
        , hide: { when: { target: $('#input1'), event: 'blur'} }
    });

但问题是 之类的东西不起作用。

  show: { when: { target: $('#input1'), event: 'focus'},
                { target: $('#questionmark1'), event: 'focus'} }

简而言之,前面的前 2 段代码工作正常,我可以添加两者以实现我的目标,但我想以正确的方式做到这一点。
我如何定位多个目标的事件来显示单个工具提示?

I have few input and select controls in my form that each of them have a small question mark icon in front of them that will show a tool tip when mouse is over that gif with help of excellent jquery jquery.qtip-1.0.0-rc3.js(with jquery-1.3.2.min.js) plug-in like this :

   $('#questionmark1').qtip({
        content: 'sample help content'
        , style: { name: 'sampleStyle' }
        , position: { corner: { target: 'bottomLeft', tooltip: 'rightTop'} }         
    });

I also want to show tool tip when ever that corresponding input field get focused and hide when get blurred . the following one do the trick but without showing the tool tip when mouse is over that gif

  $('#questionmark1').qtip({
        content: 'sample help content'
        , style: { name: 'sampleStyle' }
        , position: { corner: { target: 'bottomLeft', tooltip: 'rightTop'} }         
         , show: { when: { target: $('#input1'), event: 'focus'} }
        , hide: { when: { target: $('#input1'), event: 'blur'} }
    });

but the problem is that something like does not work.

  show: { when: { target: $('#input1'), event: 'focus'},
                { target: $('#questionmark1'), event: 'focus'} }

in short the preceding first 2 blocks of code works fine and i can add both to achieve my goal but i want do it the right way .
how can i target multiple targets'events for showing a single tool tip ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

何必那么矫情 2024-10-16 02:47:08

您不必在对 qtip() 的调用中连接所有显示/隐藏事件。我将 mouseover 事件定义为默认触发 qtip 的事件:(

$('#questionmark1').qtip({
      content: {text:'sample help content', prerender: true}
      , style: { name: 'sampleStyle' }
      , position: { corner: { target: 'bottomLeft', tooltip: 'rightTop'} }         
      , show: { when: 'mouseover' }
  });

请注意我添加的预渲染选项)

,然后为要显示 qtip 的输入手动定义事件处理程序:

$("#input1").bind("focusin", function() {
    $("#questionmark1").qtip("show");
}).bind("blur", function() {
    $("#" + this.id + "-tip").qtip("hide");
});

请参阅此处的示例: http://jsfiddle.net/andrewwhitaker/wCgAM/

唯一奇怪的是您可以通过聚焦第一个输入然后将鼠标悬停在第二个问号上来显示两个工具提示。不过,这可能很容易解决。

希望有帮助。

You don't have to wire up all of the show/hide events inside of the call to qtip(). I'd define the mouseover event as the event that triggers the qtip by default:

$('#questionmark1').qtip({
      content: {text:'sample help content', prerender: true}
      , style: { name: 'sampleStyle' }
      , position: { corner: { target: 'bottomLeft', tooltip: 'rightTop'} }         
      , show: { when: 'mouseover' }
  });

(Note the prerender option I added)

And then manually define event handlers for the input that you want to show the qtip for:

$("#input1").bind("focusin", function() {
    $("#questionmark1").qtip("show");
}).bind("blur", function() {
    $("#" + this.id + "-tip").qtip("hide");
});

See an example here: http://jsfiddle.net/andrewwhitaker/wCgAM/

The only odd thing is that you can make both tooltips show up by focusing the first input and then mousing over the second question mark. This is probably easy enough to fix though.

Hope that helps.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文