Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Solved] Pass title AND content in attr:title with separator
7th July, 17:42
Post: #1
[Solved] Pass title AND content in attr:title with separator
Is there any possible way to duplicate a behavior of the bassistance.de Tooltip system (http://bassistance.de/jquery-plugins/jqu...tooltip/)? They basically allow you to pass the title of the tooltip AND the content of the tooltip in the title attribute of the element. So you could do this:

HTML Code
<span title="The Title|Here is the content.">Testing</span>


And the script would take the part previous to the | and make it the title, then the rest would be the content. Is that possible with qTip2?
Find all posts by this user
Quote this message in a reply
12th July, 17:26
Post: #2
RE: Pass title AND content in attr:title with separator
Sure, just implement it manually Smile

JS Code
$('[title]').each(function() {
	var self = $(this),
		match = self.attr('title').match(/([^|]+)/gi);
 
	// Make sure we got the details
	if(!match || !match[0] || !match[1]) { return; }
 
	self.qtip({
		content: {
			text: match[1],
			title: match[0]
		}
	});
});

Craig Thompson
Web Developer / Designer
Craigsworks
http://www.craigsworks.com
Visit this user's website Find all posts by this user
Quote this message in a reply
20th July, 22:27 (This post was last modified: 20th July 22:28 by johndubya.)
Post: #3
RE: [Solved] Pass title AND content in attr:title with separator
That works a charm, thank you so much! I am running qTip2 inside of a live() setting, so I had to do a bit of modifying, but it works great. Here's what my code ended up looking like:

JS Code
$(".tip,.tipBtn,.tipAuto,.mmddyyyy").live("mouseover",function(event){
	var theMatch = $(this).attr('title').match(/([^|]+)/gi);
	//if no separator, fill title and text with default info
	if(!theMatch || !theMatch[0] || !theMatch[1]) { theMatch[0]=""; theMatch[1]=$(this).attr("title"); }
	$(this).qtip({
		overwrite: false, // Make sure the tooltip won't be overridden once created
		content: {
			text:theMatch[1],
			title:theMatch[0]
		},
		position: {
			adjust: {x:10,y:-25,mouse:true},
			target: "mouse",
			viewport: $(window)
		},
		show: {
			delay: 0,
			effect: false,
			event: event.type, // Use the same show event as the one that triggered the event handler
			ready: true, // Show the tooltip as soon as it"s bound, vital so it shows up the first time you hover!
			solo: true
		},
		hide: { delay:0, effect:false }
	}, event); // Pass through our original event to qTip
})
// Store our title attribute in "oldtitle" attribute instead
.each(function(i){
	$.attr(this,"oldtitle",$.attr(this, "title"));
	this.removeAttribute("title");
});
Find all posts by this user
Quote this message in a reply
Post Reply 


Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Recover title attribute content on hide baps 2 19 Yesterday 23:38
Last Post: baps
  [Solved] qtip showing content from db doesn't change when content in db changes. vtoepel 2 145 23rd April 16:02
Last Post: vtoepel
  [Solved] Tipp with title & content in title fspade 2 363 21st February 06:42
Last Post: fspade
  [Solved] Styling a['title'] iand 2 440 6th June 12:34
Last Post: iand
  [Solved] Using dynamically loaded content as well as DOM content; 'this' troubles distobj 1 1,106 2nd April 14:11
Last Post: Craig
  text from title tag disappearing behind css bg whiteaway 3 866 28th January 11:44
Last Post: Craig
  Style Title not working for font-size and font-family ForgotMyOrange 2 1,986 19th December 21:50
Last Post: ForgotMyOrange
  [Solved] Loading title attribute value as content on each display nparsons 2 945 19th November 03:42
Last Post: nparsons
  qtip + jquery validation not showing the title of the input mbarros 3 1,809 16th November 23:13
Last Post: Craig
  best way to pass parameter using url content freestyle 2 2,071 26th October 23:42
Last Post: Craig



User(s) browsing this thread: 1 Guest(s)