Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Add Title to Content with an Ajax Call
13th April, 23:07
Post: #1
Add Title to Content with an Ajax Call
I am having trouble figuring out how to add a qTip title attribute to some of the content returned from an Ajax call. I also can't seem to change the width. Could someone help me out?
JS Code
$(".qball").each(function () {
		var first = $(this).attr('first');
		var last = $(this).attr('last');
		var sport = $(this).attr('sport');
		var q = $(this).attr('q');	
$(this).qtip({
   content: {
      url: '/ajax_pu.php',
      data: { first: first, last: last, sport: sport, q: q },
      method: 'get'
   },
   position: {
         corner: {
           target: 'bottomLeft',
          tooltip: 'topLeft'
        }
      },
   style: {
   		width: 400, 
      name: 'dark'
   },
 
});
});
Find all posts by this user
Quote this message in a reply
14th April, 03:07
Post: #2
RE: Add Title to Content with an Ajax Call
I decided the best thing to do is to just set the padding to 0 and design it myself to mimic the title.

Though I noticed a few bugs:

- When mousing over the tooltips sometimes they move in from the top left corner.
- Width does not work.
- adjust screen true does not work. tooltips still showup off screen.
JS Code
$(".qball").each(function () {
		var first = $(this).attr('first');
		var last = $(this).attr('last');
		var sport = $(this).attr('sport');
		var q = $(this).attr('q');	
$(this).qtip({
   content: {
      url: '/ajax_pu.php',
      data: { first: first, last: last, sport: sport, q: q },
      method: 'get'
   },
   position: {
         corner: {
           target: 'topMiddle',
          tooltip: 'bottomMiddle'
        },
       	adjust: { screen: true}
      },
   show: { delay: 25 },
   style: {
   		 border: {
        width: 3
       },
   		width: 400, 
      name: 'dark',
      padding: 0
   },
 
});
});
Find all posts by this user
Quote this message in a reply
15th April, 16:24
Post: #3
RE: Add Title to Content with an Ajax Call
brant, unfortunately there isn't any really easy way of accomplishing this in the 1.x branches. But the 2.x branch allows you to do this really easily like so via the ajax plugin:

JS Code
$('.selector').qtip({
   content: {
      ajax: { 
          url: 'ajax.php',
          data: { tooltip: 3 }
          success: function(api, content) {
             var title = $(content).find('h3').html() // Find new title in the retrieved content
             api.set('content.title.text', title) // Set it using the api reference
          }
      }
   }
});

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
Post Reply 


Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  [Solved] Hover text and AJAX content gottihh 2 70 10th May 07:24
Last Post: gottihh
  [Solved] qtip showing content from db doesn't change when content in db changes. vtoepel 2 136 23rd April 16:02
Last Post: vtoepel
  [Solved] Add Reload to Button otti.steinhauer 3 272 29th February 19:31
Last Post: Craig
  [Solved] Tipp with title & content in title fspade 2 344 21st February 06:42
Last Post: fspade
  Position of qTip Modal from call within a tooltip chuuke 1 259 17th January 21:54
Last Post: Craig
  [Solved] add an image to the qtip? knowlton 2 984 21st October 04:58
Last Post: nevf
  [Solved] How to refresh ajax content everytime jadeoflord 1 823 11th October 03:25
Last Post: jadeoflord
  ajax call with dataTable lib hanabadler 0 665 23rd September 03:42
Last Post: hanabadler
  [Solved] How to call javascript function within Qtip? When2Meets2 7 1,099 19th September 16:49
Last Post: Craig
  Ajax call not being made from qtip sz3y1w 1 881 7th September 19:55
Last Post: Craig



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