Note that there are some explanatory texts on larger screens.

plurals
  1. POFancybox 'iframe' in AJAX loaded page
    primarykey
    data
    text
    <p>I've seen a few similar posts to my problem, but none that have helped me solve it yet.</p> <p>I have an index.php with a AJAX jQuery UI menu calling .html files brought in via AJAX when clicked.</p> <p>Within the .html files (4) I'm trying to use one fancybox via the iFrame technique. Once it's clicked on the initial homepage (displayed through first .html) the fancybox works fine. But when you click to another button on the menu that loads another .html page, the fancybox does not work. And after when you navigate back the home page where it worked on initial page load, it doesn't work again.</p> <p>I've tried debugging by moving all the jQuery libraries calls and related CSS and inline JS to the main index.php page, the site then broke. Then I tried just loading the libraries there and trying to initiate with the inline JS in each individual AJAX called .html. Then tried a few more variations of these types of debugging and still nothing.</p> <p><strong>Does anyone know how I can use fancybox via iFrame within AJAX loaded pages?</strong></p> <p><strong>! UPDATE JAN 9, here's what I'm trying now &amp; still failing (please help!):</strong></p> <pre><code>&lt;script type="text/javascript"&gt; $(document).ready(function() { /* * Examples - various */ $('#various7').load(toLoad,'',showNewContent); $("#various7").fancybox({ 'width' : '95%', 'height' : '95%', 'autoScale' : false, 'transitionIn' : 'none', 'transitionOut' : 'none', 'type' : 'iframe' }); }); &lt;/script&gt; </code></pre> <p><em>Below is full code -----------</em></p> <p>Here's my index.php markup:</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html lang="en"&gt; &lt;head&gt; &lt;meta charset="utf-8"&gt; &lt;title&gt;American Grown - in dev&lt;/title&gt; &lt;link rel="stylesheet" type="text/css" href="http://rh-dev.us.mytest.com/crown/features/css/mainstyles.css"&gt; &lt;link rel="stylesheet" href="css/jquery.ui.all.css"&gt; &lt;script src="http://jqueryui.com/jquery-1.6.2.js"&gt;&lt;/script&gt; &lt;script src="http://jqueryui.com/ui/jquery.ui.core.js"&gt;&lt;/script&gt; &lt;script src="http://jqueryui.com/ui/jquery.ui.widget.js"&gt;&lt;/script&gt; &lt;script src="http://jqueryui.com/ui/jquery.ui.tabs.js"&gt;&lt;/script&gt; &lt;!--[if lte IE 7]&gt; &lt;meta http-equiv="refresh" content="0; url=http://rh-dev.us.mytest.com/crown/features/AmericanGrown/indexie.html" /&gt; &lt;script type="text/javascript"&gt; /* &lt;![CDATA[ */ window.top.location = 'http://rh-dev.us.mytest.com/crown/features/AmericanGrown/indexie.html'; /* ]]&gt; */ &lt;/script&gt; &lt;![endif]--&gt; &lt;script&gt; $(function() { $( "#tabs" ).tabs({ ajaxOptions: { error: function( xhr, status, index, anchor ) { $( anchor.hash ).html( "Couldn't load this tab. We'll try to fix this as soon as possible. " + "If this wouldn't be a demo." ); } } }); }); &lt;/script&gt; &lt;style&gt; &lt;!--Inline Styles to override UI theme--&gt; h1 { font-family: Georgia, Regular; font-size: 30px; color: #8E4925; } h2 { font-family: Georgia, Regular; font-size: 20px; color: #000; line-height: 30px;} p { font-family: Georgia, Regular; font-size: 16px; color: #000; padding: 4px; line-height: 25px;} p.buyhead { font-family: Georgia, Regular; font-size: 18px; color: #000; padding: 4px; line-height: 25px; font-weight: bold;} .ui-tabs .ui-tabs-nav { margin:0; } .ui-widget-header { border:1px solid #AAAAAA; color:#222222; font-weight:bold; } .ui-tabs .ui-tabs-nav li { border-bottom:0 none !important; float:left; list-style:none outside none; margin:0 2.2em 1px 0; padding:0; position:relative; white-space:nowrap; } .ui-state-active, .ui-widget-content .ui-state-active, .ui-widget-header .ui-state-active { background:url("select state") repeat-x scroll 50% 50% #FFFFFF; border:1px solid #AAAAAA; color:#212121; font-weight:normal; } .ui-tabs .ui-tabs-nav { margin:0; padding:0; } .ui-widget-header { background: none; } .ui-state-default, .ui-widget-content .ui-state-default, .ui-widget-header .ui-state-default { border: 0; } .ui-tabs .ui-tabs-nav li.ui-tabs-selected { padding-bottom: 0px; } .ui-widget-header { border: 0; } .ui-state-active, .ui-widget-content .ui-state-active, .ui-widget-header .ui-state-active { background: none; } .ui-state-default, .ui-state-default, .ui-widget-header .ui-state-default { background: none; } .ui-tabs .ui-tabs-nav li a { float: left; padding: 0.5em 1.1em; } &lt;!--Using CSS sprites--&gt; #nav-example, #tabs { background:url("http://rh-dev.us.mytest.com/crown/features/AmericanGrown/imgs/nav.gif") no-repeat; width: 760px; height: 42px; padding: 0; padding-top: -2px; } #nav-example li, #nav-example a { height: 41px; display: block; width:214px; } #nav-example li { float: left; list-style: none; display: inline; text-indent: -9999em; } #nav-example-01 { width: 210px; } #nav-example-02 { width: 210px; } #nav-example-03 { width: 210px; } #nav-example-01 a:hover, a:active { background:url("http://rh-dev.us.mytest.com/crown/features/AmericanGrown/imgs/nav.gif") 0px -50px no-repeat; } #nav-example-02 a:hover, a:active { background:url("http://rh-dev.us.mytest.com/crown/features/AmericanGrown/imgs/nav.gif") -255px -50px no-repeat; } #nav-example-03 a:hover, a:active { background:url("http://rh-dev.us.mytest.com/crown/features/AmericanGrown/imgs/nav.gif") -500px -50px no-repeat; } &lt;!--End Inline Styles to override UI theme--&gt; &lt;/style&gt; &lt;/head&gt; &lt;body style="background-color: #FFFDEF;"&gt; &lt;div id="pagewrap" style=" background-color: #fff; width:800px; height: 1200px; margin: 0 auto; border-right: 1px solid #cccc99 ;border-left: 1px solid #cccc99;"&gt; &lt;div id="headerbox"&gt; &lt;center&gt;&lt;img src="http://rh-dev.us.mytest.com/crown/features/AmericanGrown/imgs/Header.gif" style="padding:40px;" border="0"&gt;&lt;/center&gt; &lt;/div&gt; &lt;div class="demo" style="margin-left: 18px; margin-top: -16px;"&gt; &lt;div id="tabs" style="border-top:1px solid #CCCC99; border-bottom: 1px solid #CCCC99; border-right:0px; border-left:0px; height: 48px;"&gt; &lt;ul id="nav-example"&gt; &lt;li id="nav-example-01"&gt;&lt;a class="item1" href="ajax/content1.html"&gt;About the Book&lt;/a&gt;&lt;/li&gt; &lt;li id="nav-example-02"&gt;&lt;a class="item2" href="ajax/content2.html"&gt;Join us on Facebook&lt;/a&gt;&lt;/li&gt; &lt;li id="nav-example-03"&gt;&lt;a class="item3" href="ajax/content3.html"&gt;Get email Updates&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;div id="tabs-1"&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>Here's the code I have near the initial head in each AJAX .html page.</p> <pre><code>&lt;script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"&gt;&lt;/script&gt; &lt;script src="http://cdn.jquerytools.org/1.2.6/full/jquery.tools.min.js"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="http://rh-dev.us.mytest.com/crown/features/AmericanGrown/fancybox/jquery.mousewheel-3.0.4.pack.js"&gt; &lt;/script&gt; &lt;script type="text/javascript" src="http://rh-dev.us.mytest.com/crown/features/AmericanGrown/fancybox/jquery.fancybox-1.3.4.pack.js"&gt; &lt;/script&gt; &lt;link rel="stylesheet" type="text/css" href="http://rh-dev.us.mytest.com/crown/features/AmericanGrown/fancybox/jquery.fancybox-1.3.4.css" media="screen"&gt; &lt;!--JS for Fancybox iFrame buybtn--&gt; &lt;script type="text/javascript"&gt; $(document).ready(function() { /* * Examples - various */ $("#various7").fancybox({ 'width' : '95%', 'height' : '95%', 'autoScale' : false, 'transitionIn' : 'none', 'transitionOut' : 'none', 'type' : 'iframe' }); }); &lt;/script&gt; &lt;!--End JS for Fancybox iFrame buybtn--&gt; </code></pre> <p>And calling to action with:</p> <pre><code>&lt;a id="various7" href="http://rh-dev.us.mytest.com/crown/features/AmericanGrown/iframe/buybutton.html" name="various7"&gt;&lt;img src="http://rh-dev.us.mytest.com/crown/features/AmericanGrown/imgs/buythebook_btn.png" style="margin-top:-50px;" " border="0"&gt;&lt;/a&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload