views:

393

answers:

2

I want to display a QTIP (http://craigsworks.com/projects/qtip/) after my mouseover is longer then 1 second on a link. how is this possible?

If im with the mouse over the element less then 1 second, nothing should happen. I have tried the below code, but my browser crashes:

$(".Details").bind("mouseover", function() 
{
  t= setTimeout($(this).qtip({ args... }), 1000); });
  $(".Details").bind("mouseout", function() { clearTimeout(t); 
});
+3  A: 

In the mouseover event, set a timeout for a second. In the mouseout event, cancel the timeout. In the timeout function, display your qtip.

Anthony Mills
i tried it, but my browser crashes :Swhats wrong? $(".Details").bind("mouseover", function() { t= setTimeout($(this).qtip({ args... }), 1000); }); $(".Details").bind("mouseout", function() { clearTimeout(t); });
k0ni
It can be tricky to figure out where to store the data; a global variable might not work as well if you have multiple instances. Try using element data: `$(".Details").bind("mouseover", function (e) { var me = this; $(this).data("qtip", setTimeout(function () { $(me).qtip({args...}); }, 1000)); });` and `$(".Details").bind("mouseout", function (e) { clearTimeout($(this).data("qtip"));`. However, I think that the real answer might be the one from bendewey before; I'm not sure why it doesn't work for you.
Anthony Mills
+1  A: 

Set the show.delay property on the qTip plugin.

$(function() {
  $('#myDiv').qtip({
    content: 'My tooltip',
    show: { delay: 1000 }
  });

});
bendewey
No, i tried that.the problem is, it shows it even im not hovered more than 1 second!
k0ni
in your sample your binding to mouseover/out, you should be able to just have my code on the top of your page.
bendewey
what if i only need the delay onmouseover, but not onClick?
andufo