Facebox Problems

Wyze1 - February 26, 2008 - 08:12

Hi guys

I'm busy with a custom module that utilizes http://famspam.com/facebox/ when implementing the script in my module the data displays twice. Does anybody have a clue why drupal does this? When testing this from outside drupal it works fine though.

Thanks

Facebox Snippet

toddk - May 13, 2008 - 01:32

Hi,

Can anyone provide a snippet of code that demonstrates the use of the facebox library?

I have the following code:

drupal_add_js('misc/facebox/facebox.js');
drupal_add_css('misc/facebox/facebox.css');

drupal_add_js(
'jQuery(document).ready(function() {
     jQuery(\'a[rel*=facebox]\').facebox();});',
   'inline');

...
$blockContent = "<center><a href=\"#info\" rel=\"facebox\"><img src=\"" . $imageUrl . "\" /></a></center>";

Where $blockContent is the content to be displayed in the block I am generating and $imageUrl is a valid path to an image being displayed. When I click on the image, nothing seems to happen. I don't get any errors in firebug and can't figure out whether or not the facebox library is getting loaded correctly.

Does anyone have any suggestions?

Thanks!!

Todd Krokowski
http://toddkrokowski.blogspot.com

A fix...sort of!

toddk - May 31, 2008 - 20:56

To answer my own question, my drupal_add_js/css function calls were incorrect...it should have been:

drupal_add_js('misc/facebox/facebox.js','core');
drupal_add_css('misc/facebox/facebox.css','core');

Also, I moved my jQuery code to invoke facebox into an external file. The combination of these two things finally got me up and running but things still didn't go as smoothly as I would have liked. I ended up having to fix the paths within the facebox CSS so that they were relative and not absolute. I was never able to get facebox to behave as advertised and had a lot of issues with Firefox for the Mac. Needless to say I switched to: http://jquery.com/demo/thickbox/ and am much happier! :-)

Todd Krokowski
http://toddkrokowski.blogspot.com

 
 

Drupal is a registered trademark of Dries Buytaert.