views:

595

answers:

2

Hey you lot, I've been working on integrating Colorbox (a lightbox alternative) into a site.

Ok, so my head file is:

<head>
<script language="javascript" type="text/javascript" src="js/jquery.js"></script></script>-
<link type="text/css" media="screen" rel="stylesheet" href="../colorbox/colorbox.css" />
<script type="text/javascript" src="../colorbox/jquery.colorbox.js"></script>
<script type="text/javascript">
    function saveToBook() { 
        $.fn.colorbox({inline:false, href:'../index.html'}); 
    };
</script>
</head>

My Link is as follows:

<a href="#save-to-book" onclick="javascript:parent.saveToBook();return false;" class="recipe-links">Save to Cookbook</a>

The only output I recieve (from FireBug) is:

$.fn.colorbox is not a function
+4  A: 

My best guess would be that ../colorbox/jquery.colorbox.js is not the correct path, are you sure it's not something like this?

<script type="text/javascript" src="js/colorbox/jquery.colorbox.js"></script>

Also, your script should be more like this:

$(function() {
  $("a[href='#save-to-book']").click(function() {
    $(this).parent().colorbox({inline:false, href:'../index.html'});
    return false;
  });
});

And just remove your current function and the onclick from the anchor itself.

Nick Craver
Just for the record, not sure who has been voting this up but the client wanted a standard JavaScript function not jQuery and jquery.colorbox.js is being added properly - sorted now anyway, thought I would just put this here.
Neurofluxation
@Neurofluxation - Actually the problem **was** that it was *not* being added properly, since posting it on a different server worked, the file, path or permissions, whatever the issue, it was not being included in the page.
Nick Craver
+4  A: 

Hey, sorry for wasting peoples time - I had been running this on my local machine.

I just decided to upload it to a beta server and it all functions fine, obviously didn't like my path names :)

Thanks @NickCraver for giving it a shot, and cheers @PetersenDidlt

Neurofluxation