You will recieve your password to this address. Address is not made public.

Your preferred username that is used when logging in.

Tooltip set using setFocus() not disappearing Created Aug 19, 2010

This thread is solved

Views: 1174     Replies: 2     Last reply Aug 19, 2010  
You must login first before you can use this feature

bravo_kernel

Posts: 7

Registered:
Aug 19, 2010

Tooltip set using setFocus() not disappearing

Posted: Aug 19, 2010

I am a starting JQTools enthousiast so this might be a very obvious/dumb question but I have a page with three (form) input fields using tooltips.

When the page is loaded focus is set to the first field using the following function:

function setFocus(e){
	jQuery('#' + e).focus();
}

The first field renders the tooltip as expected using this code:

$("form :input").tooltip({
	position: "center right",
	offset: [-2, 10],
	effect: "fade",
	opacity: 0.7
});

And now the problem in reproducable steps:

1. fresh pageload shows the tooltip for field1 (good)
2. Now selecting field2 shows the tooltip for field2 but also keeps showing field1's tooltip (not good)
3.Selecting field1 and then field2 does make the tooltip for field1 disappear

Is there some method to make field1 to disappear while executing step2?

Any help is appreciated, keep up the good work!

bravo_kernel

Posts: 7

Registered:
Aug 19, 2010

» Tooltip set using setFocus() not disappearing

Posted: Aug 19, 2010

Reply to: Tooltip set using setFocus() not disappearing, from bravo_kernel
In the meantime I have discovered onShow() which looks like the solution but I need some help to get it right. The following code creates "tooltip ghosting" when changing fields quickly.

	$("form :input[title]").tooltip({
	onShow: function() {
		this.getTrigger().focus();
	}

Any idea how the focus could be limited to only that case where getTrigger() does not have focus already?

Big TIA

bravo_kernel

Posts: 7

Registered:
Aug 19, 2010

» » Tooltip set using setFocus() not disappearing

Posted: Aug 19, 2010

Reply to: » Tooltip set using setFocus() not disappearing, from bravo_kernel
Allright guys, I have a solution/workaround that makes me pretty happy. The code should speak for itself.

function setFocus(e){
	jQuery('#' + e).focus();
	jQuery('#' + e).addClass("autoFocussed");
}

$(document).ready(function() {
 	$("form :input[title]").tooltip({
 		onShow: function() {
			if (this.getTrigger().hasClass("autoFocussed")){
				this.getTrigger().focus();
				this.getTrigger().removeClass("autoFocussed");
			}
 		}
 	});
});


Great toolset, this thread can be closed!