Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Solved] Title and Text issue
28th April, 02:13
Post: #1
[Solved] Title and Text issue
I have the title and text being pulled as you can see from the qtip code below. what i'm wondering is... if qtip can't find any "text" it replicates the "title" information into the text area of the tooltip. i would like it to display nothing in the text area and only the title info. is there anything I can do to change this behavior?

JS Code
$(document).ready(function()
{
   $('a.recapp').each(function(i)
   {
      $(this).qtip({
      content: {
         text: $(this).find('span.recapp').html(),
		 title: {
			text: function(api) {
				return $(this).attr('title');
				}
			}
      },
      position: {
         my: 'left center',
         at: 'right center',
         viewport: $(window)
      },
       style: {
		   tip: false,
           classes: 'ui-tooltip-light ui-tooltip-rounded ui-tooltip-shadow'
      },
      show: { solo: true },
      hide: { fixed: true },
   });
 });
});
Find all posts by this user
Quote this message in a reply
4th May, 04:47
Post: #2
RE: Title and Text issue
There are MANY ways to do this:
  • Use a simple ternary in the context.text property to check if the child SPAN exists (though this yields ugly results IMO)
    JS Code
    text: $(this).find('span.recapp').length >= 1 ? $(this).find('span.recapp').html() : ' ',
  • Have two qTip inits, one with a jQuery selector for links without the child SPAN and one for links with the child SPAN:
    JS Code
    $('a.recapp').has('span.recapp').each(function(i) ...
     
    $('a.recapp:not(:has("span.recapp"))').each(function(i) ...
  • Use different classes to differentiate the two types of tips and so they can be initialized separately
    JS Code
    $('a.recapp .withSpan').each(function(i) ...
     
    $('a.recapp .withoutSpan').each(function(i) ...
  • Set a couple of default configuration blocks and use a ternary to swap out the qTip init based on whether the child SPAN exists or not via $.extend()

    http://jsfiddle.net/kiddailey/6PsU2/
    JS Code
    $(document).ready(function()
    {
        var 
            withSPANConfig = {
                content: {
                    text: $(this).find('span.recapp').html(),
                    title: {
                        text: function(api) { return $(this).attr('title'); }
                    }
                }
            },
            withoutSPANConfig = {
                content: {
                    text: function(api) { return $(this).attr('title'); }
                }
            }
     
       $('a.recapp').each(function(i)
       {
            $(this).qtip($.extend(
                $(this).find('span.recapp').length > 0 ? 
                    withSPANConfig : withoutSPANConfig 
                ,
                {
                    position: {
                        my: 'left center',
                        at: 'right center',
                        viewport: $(window)
                    },
                    style: {
                        tip: false,
                        classes: 'ui-tooltip-light ui-tooltip-rounded ui-tooltip-shadow'
                    },
                    show: { solo: true },
                    hide: { fixed: true },
                }
            ));
        });
    });
  • etc.
Find all posts by this user
Quote this message in a reply
4th May, 13:42
Post: #3
RE: [Solved] Title and Text issue
Excellent. thank you
Find all posts by this user
Quote this message in a reply
Post Reply 


Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  [Solved] Position issue in FF/Safari with fixed width body / auto margin jwf 2 79 10th May 17:02
Last Post: jwf
  set("content.text") triggers reposition() msavona 1 61 10th May 00:02
Last Post: Craig
  [Solved] Closing modal issue ganniv 2 214 11th April 20:39
Last Post: ganniv
  [Solved] updating title bug dfrankson 1 136 10th April 18:59
Last Post: Craig
  [Solved] Format Text and CSS Style franmm25 1 207 5th April 15:33
Last Post: Craig
  Safari youtube preview issue jjones3535a 2 235 19th March 17:29
Last Post: TickleKitty
  [Solved] Reusing title from HTML's title tag fspade 4 347 2nd March 07:20
Last Post: fspade
  QTIP IE 8 Issue Changing Width slhilbert 6 470 28th February 15:10
Last Post: slhilbert
  [Solved] Adding a handler to something in qtips title ewalsh 3 329 26th February 12:06
Last Post: ewalsh
  [Solved] Closed thread: How to use title from HTML's title tag? fspade 2 311 12th February 08:32
Last Post: fspade



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