Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to use a callback function as content-specifier
25th August, 11:07
Post: #1
How to use a callback function as content-specifier
Unfortunately, I haven't figured this one out yet.

Unstead of some url with parameters, or static text - I would like to supply a callback function, which would have access to the trigger element, the event, and the API to provide the content for my qTip.

This way, I could actively use the state of the browser window (fx form values) at the moment the tooltip renders.

(I hope I'm posting in the right forum here)
Visit this user's website Find all posts by this user
Quote this message in a reply
25th August, 18:21
Post: #2
RE: How to use a callback function as content-specifier
This isn't supported in the 1.0 releases unfortunately. I like the idea though... nice alternative to regular text, so it's been added to the 2.0 nightlies.

Although, you should be able to do this easily enough by just using an .each() loop- and doing you checks etc. before you setup your tooltip:

JS Code
$('.selector').each(function() {
   var content = 'blah';
   $(this).qtip({ content: content });
});

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
25th August, 18:36
Post: #3
RE: How to use a callback function as content-specifier
That's indeed how I solved it, and which works for the instance where I needed it. In another instance, I decided to use the onRender api function to do an ajax request and set title and content from the JSON response object. A case for which I could have imagined using a setting telling qTip to tell jQuery to parse the response as JSON.

That JSON object could have been fed into another callback function.

Or, and that's perhaps more obvious - could contain a subset of options qTip understands, essentially controlling qTip from the server side.

Anyway, just a thought. Support for: content: function(api, event) { } would already be a bliss. Especially if I could return false to suppress actually showing the tooltip.
Visit this user's website Find all posts by this user
Quote this message in a reply
31st January, 07:06
Post: #4
RE: How to use a callback function as content-specifier
I solved with beforeShow api method like this:
[
beforeShow:function()
{
$.ajax({url:'soewhere',
onSuccess:function()
{
//get your content and put it in the tcontent
},
onError:function()
{
return false;
//and the tip won't be shown
}
});
}
]
wish it helps
Find all posts by this user
Quote this message in a reply
Post Reply 




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