views:

3376

answers:

6

Hello all,

I am trying to implement a fancybox. http://fancybox.net/howto

I want to call this function on an an element. Full JS file. http://fancybox.net/js/fancybox/jquery.fancybox-1.2.1.js

$.fn.fancybox = function(settings) {

I have done this:

$(document).ready(function() { 
    $("a#inline").fn.fancybox();  
});

However, I keep getting this error (through firebug):

$("a#inline").fn is undefined
[Break on this error] $("a#inline").fn.fancybox();

What does this mean? I am basically having instantiating problems.

Please help.

EDIT

The HTML file:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
<html xmlns="http://www.w3.org/1999/xhtml"&gt;
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Technologies</title>
<link href="style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="fancy/jquery-1.3.2.min.js"></script>
<script type="text/javascript" src="fancy/jquery.fancybox-1.2.1.js"></script> 
<link rel="stylesheet" href="fancy/fancybox.css" type="text/css" media="screen" />
<script type="text/javascript">
$(document).ready(function() { 
    $("a#inline").fancybox();  
}); 
</script>
</head>
<body>
<?php
include_once ("header.php");
?>
<div id="channel_calc">
How many Channels do I need?
<span id="yellow"><a id="inline" href="#ddm">Channel Calculator</a></span>
</div>
A: 

I think you forgot to also include jquery itself. Fancybox depends on jquery.

<script type="text/javascript" src="path-to-file/jquery.js"></script>
richard
I have included it and I can access it bia my browser.
Abs
A: 

$("a#inline").fn.fancybox(); should be $("a#inline").fancybox();

Frederik Vig
I have tried this also and I get an error that says fancybox is not a function?! I have used many JQuery plugins before and they were straightforward. I have no idea whats going in here. Probably something simple and stupid.
Abs
Check your path to your fancybox script and make sure it is included before you make a call to the fancybox function.
Frederik Vig
Yep, I checked this too. I don't know what else I can do to debug this or solve this.
Abs
I'm pretty sure your paths are wrong. Do a view source and copy/paste the paths into your browser. Also make sure that jQuery is included before the fancybox script.
Frederik Vig
I also did that and the script appeared fine. Also I am looking at the scripts via firebug. This is getting strange!
Abs
+1  A: 
$('#inline').fancybox();

.fn refers to the prototype.

meder
I get this: $("#inline").fancybox is not a function[Break on this error] $("#inline").fancybox();
Abs
Check firebug net tab and see what's missing.
meder
Make sure your script references look like this:http://jsbin.com/uqezi
meder
I've got console and script tabs open. If this is what you mean?
Abs
Make your web page as minimalistic as possible, try mimicking what I have. Post a public url if you could.
meder
I'm developing on my localhost and i have a very minimalist page. I have pasted relevant HTML.
Abs
Update your <script> src to the absolute URI:http://fancybox.net/js/fancybox/jquery.fancybox-1.2.1.jsIf it works then it's an issue with how you saved it. How is your site setup locally? Virtualhost? Maybe you need to do src="/fancy/foo.js"
meder
Also please verify that you actually have the files inside of the 'fancy' directory. Somewhere along the lines you just made a simple mistake, be thorough.
meder
I have verified this, I have even downloaded the files again. Does it matter if I am using relative files?
Abs
Did you try absolutely linking them?
meder
Yes, I even copied the URL you are using and I still get the same damn errors. Seriously what could possible be causing this. I am happy to listen to remote ideas! If I had some idea of what was going on I would of at least had a chance.
Abs
Before anyone says it, I have been clearing caches after every test.
Abs
OK PROBLEM SOLVED - I should of looked in my header file, I was requiring JQuery there too!! Sorry everyone. :(
Abs
That's what I meant by making it more minimalistic, only the bare necessities.. which would be 3 script elements and html.
meder
Sorry, I know. Thanks :)
Abs
+1  A: 

Di you find the error? Had the same problem. Solution was that i had included twice a javascript file, rather i included the jquery.js file twice.

jNik
+1  A: 

I was also having this problem and found that I had included jquery.js twice. Removing the second reference fixed the error I was getting from the fancybox call

Ben Trevino
A: 

As Ben said, make sure jQuery is not being included twice by accident.

Andy