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

Your preferred username that is used when logging in.

Pass specific trigger into onBeforeShow Created Dec 15, 2009

This thread is solved

Views: 2422     Replies: 2     Last reply Mar 1, 2010  
You must login first before you can use this feature

Aramaki

Posts: 25

Registered:
Sep 11, 2009

Pass specific trigger into onBeforeShow

Posted: Dec 15, 2009

Hi, dear all.

I hope you can show me the way to the solution of the following proble^

I have multiple triggers and its contents on the page

How do I link specific content to trigger?

I guest I can grab it through $(Obj).parents('div').find('.content') but how do I pass the trigger Obj?


	<div class="item">
		<div class="trigger">some text</div>
		<div class="content">some content some content some
 content some content some content </div>
	</div>
	<div class="item">
		<div class="trigger">another text</div>
		<div class="content">another content another content
 another content another content </div>
	</div>
	<div id="tooltip"> </div>


$(function() {
	if ($(".trigger").length) {
		$(".trigger").tooltip({
			tip: '#tooltip',
			lazy: false,
			onBeforeShow: function() {
				$("#tooltip").html()
			}
		}).dynamic({
			bottom: {
				direction: 'down',
				bounce: true
			}
		});
	}
}

jtnix

Posts: 7

Registered:
Dec 17, 2009

» Pass specific trigger into onBeforeShow

Posted: Jan 9, 2010

Reply to: Pass specific trigger into onBeforeShow, from Aramaki
Use the jQuery .data functions to store data in the trigger element:

http://docs.jquery.com/Core

ToolTip uses this to store the timer data in the tip element - look at the code to see how.

Good Luck,

Jt

Aramaki

Posts: 25

Registered:
Sep 11, 2009

» Pass specific trigger into onBeforeShow

Posted: Mar 1, 2010

Reply to: Pass specific trigger into onBeforeShow, from Aramaki
The right way is to use this.getTrigger()

Code sample

	$(".examples .info img").tooltip({
		tip: '#tooltip',
		effect: 'toggle',
		lazy: false,
		fadeOutSpeed: 0,
		predelay: 400,
		delay: 100,
		offset: [-5, 0],
		onBeforeShow: function() {
			$("#tooltip").html(this.getTrigger().next().html());
		},
		position: "top center",
		api: true
	});