Tooltips - Passing parameters

Page: 1

Author Post
Member
Registered: Oct 2012
Posts: 19
With floatbox class, I pass parameters this way :
<a href="/ajaxfb.php?option=proxim&fbid=' . $user->id . '" class="floatbox" data-fb-options="type:ajax width:500 ...

This works fine.

I try the same for the fbTooltip class, but the paramaters don't pass :
<img width="32" src="'.$user->getThumbAvatar().'" class="fbTooltip" data-fb-tooltip="type:ajax width:500 height:200 source:ajaxtip.php?option=tooltip&fff=1

And I need these parameters (option and fff) to construct tooltip content in my ajaxtip.php file.

How can I do this ?
Administrator
Registered: Aug 2008
Posts: 3382
I'm not sure that I understand the question.

Your ajaxtip.php file would read the 'option' and 'fff' parameters from PHP's global $_GET variable, but this has nothing to do with Floatbox, which is client-side.

You can assign floatbox options to a tooltip based on class name by using the className option in the data-fb-tooltip attribute. For example, with data-fb-tooltip="source:xyz.php className:myClass", the tooltip will pick up any class options assigned to the 'myClass' class.

You can also assign options to tooltips by assigning them to the 'tooltip' type options in options.js or in fbTypeOptions on the page. See the instructions for details.

And of course, options can be set directly in the data-fb-tooltip attribute.

I hope this answers your question, whatever that question might be. ;)


Correction: Assigning options through the className setting works for only some options. Assigning preference to the 'tooltip' type options and placing options directly in the data-fb-tooltip attribute are the only reliable approaches. I'll do some work in the next release to try and get class-based options to work as expected in tooltips and context boxes.
« Last edit by admin on Tue Oct 23, 2012 1:59 pm. »
Member
Registered: May 2011
Posts: 17
I just ran into this snag too:

<button class="fbTooltip" data-fb-tooltip="source:ajax_tooltip.php?tipid=VALUENOTPASSED&tipid2=NOTPASSED type:ajax">Tooltip</button>

For some reason the ajax is called and the tipid parameter is passed but the value is not set and none if the additional parameters after the ampersand is passed.

I upgrade from 5.00 to 6.03 and both versions don't work. Maybe we found a rare bug?

-Eric
Administrator
Registered: Aug 2008
Posts: 3382
No bug. You just need to put backquotes around the source value so it can parse correctly.
data-fb-tooltip="source:`ajax_tooltip.php?tipid=VALUENOTPASSED&tipid2=NOTPASSED` type:ajax"

You should also encode the & as &amp; because it is appearing in HTML markup, but you can usually get away without this.
Member
Registered: May 2011
Posts: 17
That was it. I tried the backticks earlier but I must have had them in the wrong place. And you're right, I am getting away with a plain '&'.

Hey, idea, under your demo documentation for context menus:

consider changing:
data-fb-context="source:picker.html type:ajax instanceName:picker"

to:
data-fb-context="source:`picker.html?menu_id=123` type:ajax instanceName:picker"

and I think that'll give some of us folks a hint to using dynamic tooltips and context menus.
Thanks!
Administrator
Registered: Aug 2008
Posts: 3382
I could do a better job of documenting the requirement for back-quoting in the instructions. It's not particular to the 'source' option, and in fact shows up most commonly when assigning captions.

Quoting from the instructions:
Quote
The option string syntax is quite flexible. Name:value pairs can be separated by spaces, semi-colons, commas or ampersands. The delimiter between a name and its value can be a colon or an equals sign. Pixel values can be given with or without the 'px' suffix.
"colorTheme:red width:200", "colorTheme:red; width:200px;", "colorTheme:red, width:200" and "colorTheme=red&width=200" are all allowed and equivalent.


The following 6 characters have meaning as separators in the options string:
: ; , = & and space
Any option value that contains one or more of these characters in its value requires backquotes around the entire value so that these characters are understood to be part of the value string and are not used as name:value separators by the parsing routine.

Page: 1