Page 1 of 1

Fancy Box Body onLoad not working - anyone know why?

Posted: Thu Jul 28, 2011 4:55 am
by simonmlewis

Code: Select all

if ($paid == "y")
{
echo "<script>
$(document).ready(function(){
 $(\"#addop\").fancybox({
  'width': 640,  //or whatever
  'height': 400.
  'type': 'iframe' // see this?
 });
});
</script>
<body onload=\"$('#addop').trigger('click');\">";
}
The addop is set in a DIV further down, but my question is can you use SCRIPT like this within an 'echo' in the way I have done it?

It has to be like this, so it runs only when there is something in the $paid variable.

Re: Fancy Box Body onLoad not working - anyone know why?

Posted: Fri Aug 05, 2011 11:17 pm
by yacahuma
I am not sure what do you want but take a look at this http://defunkt.io/facebox/

Re: Fancy Box Body onLoad not working - anyone know why?

Posted: Sat Aug 06, 2011 3:31 am
by simonmlewis
Thanks I will have a play and see how I get on.
I've already written my scripts. The problem I often have is if the script is being used in one part of the page, such as admin.php, then test.inc where the same script is entered, will not work.

For example: At the top in admin.php I have "Operators" shown with an "Add" link. The 'Add' link opens a 'fancybox' with a form. Nice and neat.
However, If the user has no operators, I want the operators.inc page to show the Add link too (a nice big friendly button to start at ), but it will not work. It's identical code.

I've even used identical code, but changed the #name in case it was getting confused. Still no go.

Very annoying.

Re: Fancy Box Body onLoad not working - anyone know why?

Posted: Thu Aug 11, 2011 11:29 am
by simonmlewis
Hi.
I've not got this working without any of the flaw of the 'fancybox'. Many thanks.

Re: Fancy Box Body onLoad not working - anyone know why?

Posted: Fri Aug 12, 2011 4:37 am
by simonmlewis
How do you use this part of it?

[text]Attach It onLoad

While calling facebox() on any anchor tag will do the trick, it's easier to give your Faceboxy links a rel="facebox" and hit them all onLoad.
jQuery(document).ready(function($) {
$('a[rel*=facebox]').facebox()
})
[/text]

Do you put that code in a <script></script> tag? As that doesn't work for me.
It would be useful to have this work, as one particular page does need to highlight something important to the user, and this would be a smart way to do it.