0

I have a set of jquery tabs for top navigation (tabs are just text links, not "graphical" tabs). When you click a link, I want a fancybox to open containing an external html file. This is not happening. No fancy box is launching. Below is my code. Could you guys/gals let me know what I am doing wrong and how to fix? I'm having trouble figuring it out. Thanks.

Scripts:

<link rel="stylesheet" href="../css/jquery.fancybox.css" type="text/css"  />
<script language="javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script language="javascript" src="http://code.jquery.com/ui/1.9.2/jquery-ui.js"></script>
<script language="javascript" src="../js/fancybox/jquery.fancybox.js"></script>

HTML:

<script type="text/javascript">
$(document).ready(function() {

    $("#lesson-tabs").tabs();

    $(".tabs-content").fancybox({

                'type':'iframe',
                'maxWidth'  : 580,
                'maxHeight' : 390,
                'fitToView' : false, 
                'width'     : 500,
                'height'    : 300,
                'autoSize'  : false
    });

});
    </script>

<div class="overhide" id="lesson-tabs">
        <ul>
          <li>
               <span class="fun2learn-add" ></span>
               <a href="lessons/addition1.html" class="first-class2 tabs-content" >Addition</a>
           </li>
           <li>
               <span class="fun2learn-subtract" ></span>
               <a href="lessons/subtraction1.html" class="first-class2 tabs-content">Subtraction</a>
           </li>
    </ul>
</div>

lessons/addition1.html code for fancybox:

<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Just try it!</title>
<style>
div {font-family:Arial, Helvetica, sans-serif;font-size:16px;}
.blkstyle {display:block;}
input[type=submit] {margin-top:10px;}
</style>
</head>

<body>
<div>
<p>If you have 14 apples, Justin has 12 and Mary gives you 7 more apples, but only gives Justin 3 apples, how many apples would you and Justin have altogether?</p>
<form>
<span class="blkstyle"><input type="radio" name="apples" /><label>24</label></span>
<span class="blkstyle"><input type="radio" name="apples" /><label>42</label></span>
<span class="blkstyle"><input type="radio" name="apples" /><label>36</label></span>
<span class="blkstyle"><input type="radio" name="apples" /><label>16</label></span>
<input type="submit" value="Answer" />
</form>

</div>
</body>
</html>

lessons/subtraction1.html code for fancybox:

    <!DOCTYPE HTML>
    <html>
    <head>
    <meta charset="utf-8">
    <title>Just try it!</title>
    <style>
    div {font-family:Arial, Helvetica, sans-serif;font-size:16px;}
    .blkstyle {display:block;}
    input[type=submit] {margin-top:10px;}
    </style>
    </head>

    <body>
    <div>
        <p>Jamie has 38 lives left in play for his new video game.  
        He loses 6 lives on level Nine and 5 lives on level Twelve.  
        He hasn't gained anymore lives until level Twenty, where he gets 4 more, 
        but loses 1 life in play.  How many lives does Jamie have left in play?</p>
        <form>
            <span class="blkstyle"><input type="radio" name="apples"  /><label >26</label></span>
            <span class="blkstyle"><input type="radio" name="apples" /><label>30</label></span>
            <span class="blkstyle"><input type="radio" name="apples" /><label>22</label></span>
            <span class="blkstyle"><input type="radio" name="apples" /><label>16</label></span>
            <input type="submit" value="Answer" class="blkstyle"/>
        </form>

    </div>
</body>
</html>

enter image description here

Chris22
  • 1,973
  • 8
  • 37
  • 55
  • You only need one single instance of fancybox (you are loading the normal and the pack versions) ... maybe there is a conflict – JFK Dec 04 '12 at 21:20
  • @JFK thanks. I'm not sure that is the issue. I've removed the script. However, in IE 7/8/9, the addition1.html external page is displayed - as if by default. It also opens in the fancybox when I click the 'addition' link, but that external .html page should not be displayed on the page by default. Do you or anyone know why this is happening? In Chrome and Firefox, only the tab links are displayed, which is what is expected. – Chris22 Dec 05 '12 at 16:13
  • Well, your code works as you can see in this **[JSFIDDLE](http://jsfiddle.net/FaZxc/)** .... of course fancybox won't find the pages but is launching. You may have a js error somewhere. BTW `hideOnContentClick` is not a valid API option for v2.x check this http://stackoverflow.com/a/8404587/1055987 – JFK Dec 05 '12 at 19:33
  • I have added a screenshot and removed the `hideOnContentClick` option in the jquery -- that is the only javascript/jquery I am using other than the jquery tabs script which I have not altered the code in any way. The files I am using are doctype html for html5. I have no idea why in IE I am seeing the contents of the addition1.html page as default. I checked your Fiddle and ran it in IE, you are right, the content is not on the page, but as you can see, it is on mine. I have deleted cache as well in the browser (links are blue, not visited - fresh page) but I am still seeing the content. – Chris22 Dec 05 '12 at 20:23
  • can you share a link or create a sample that reproduces the issue? otherwise we can keep guessing – JFK Dec 05 '12 at 20:49
  • @JFK, I don't have a site on the web for public viewing. A "sample" is that I have provided the entire code (code for each external html page included) as well as posted a screenshot from my local drive. Unfortunately for me, there is nothing else I can provide to show a reproduction of the results I am getting. Thanks for your time, I appreciate your help. – Chris22 Dec 05 '12 at 22:26

0 Answers0