Search code examples
javascriptqtip

qTip: prevent hiding the tip two times successively


First of all sorry guys for posting the question here. The support forum seems to be almost dead.

So I've run into a bug in the qtip plugin or my code. When I call .qtip('hide') twice or more times consecutively, the tooltip will hide and never show again when calling .qtip('show').

The way to reproduce:

el.qtip('hide');el.qtip('hide');el.qtip('show'); \\ -> bug, the tip is not shown el.qtip('hide');el.qtip('hide');el.qtip('hide');el.qtip('show'); \\ -> bug, same

Consecutive show works good...

el.qtip('show');el.qtip('show');el.qtip('hide');el.qtip('show'); \\ -> pass

Non - consecutive hide also works good:

el.qtip('hide');el.qtip('show');el.qtip('hide');el.qtip('show'); \\ -> pass

The question is:

How to make things work? The qTip api does not give me a way to find if the tip is hidden or shown. How can I know that? I can check if the qTip is hidden not to hide it twice.

Possible source of problem:

The qtip causing errors is constructed in a rather tricky way:

qtip({
            content: text,
            position: {
                corner: {
                    target: 'rightMiddle',
                    tooltip: 'leftMiddle'
                }
            },
            style: {
                tip: {
                     corner: 'leftMiddle',
                },
                border: {
                    radius: 11,
                    width: 4
                },
                name: 'red'
            },
            show: {
                delay:0,
                ready: true,
                fixed:true,
                when: { target: false, event:false },
                effect: function() {//.stop(true, true)
                    $(this).effect("drop", { direction: "down", mode: "show" }, 240)
                }
            },
            hide: {
                delay:0,
                fixed:true,
                when: { target: false, event:false },
                effect: function() {//.stop(true, true)
                    $(this).effect("drop", { direction: "down", mode: "hide" }, 240)
                }
            }
        })

To test this, you can go to www.buxdial.com/oldo/register.php, type anything in the captcha field, go to debugger and run the tests, replacing el with code.TIP


Solution

  • If you have just one instance of a qtip on your page you can check to see if the qtip is currently showing by searching for the qtip-active class. Here is an example using jquery on how to check:

    if($('div.qtip-active').length) {
       alert("qtip is currently showing");
    }
    else {
       alert("qtip is hidden");
    }