2 番目から 4 番目のタブに iFrame がロードされた JQuery タブを持つ Web ページがあります。私の問題は、最初のタブに追加したボタンにあります。そのボタンを押すと、次のタブに変わります。
編集1:これは私の問題を示すフィドラーです。http://jsfiddle.net/lochalan/AXa9J/
ウェブページ:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Student Application</title>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.1/themes/base/jquery-ui.css" />
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.1/jquery-ui.js"></script>
<script src="/user/tabs.js" type="text/javascript"></script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css">
html {
font-size:10px;
}
.iframetab {
width:100%;
height:auto;
border:0px;
margin:0px;
position:relative;
top:-13px;
}
.ui-tabs-panel {
padding:5px !important;
}
.openout {
float:right;
position:relative;
top:-28px;
left:-5px;
}
</style>
</head>
<body>
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr><td>
<img src="img/logo960x100moodle.png" width="960" height="92" alt=""><br>
</td></tr>
</table>
<div id="tabs">
<ul>
<li><a href="#tabs-1">Instructions</a></li>
<li><a class="tabref" href="#tabs-2" rel="/user/application-tab.php">Student Information</a></li>
<li><a class="tabref" href="#tabs-3" rel="/user/emergency-tab.php">Emergency Contact</a></li>
<li><a class="tabref" href="#tabs-4" rel="/user/healthform-tab.php">Health Form</a></li>
</ul>
<div id="tabs-1" class="tabMain">
<h2>Welcome to QSI Shekou!</h2>
<p>This application is designed to give the school all the information needed to make an informed decision as to whether QSI is the best school for your child. We believe all children can be successful and we are proud that you have choosen QSI Shekou as that place. In the next few minutes, you will be presented with 3 seperate application forms. The first application gathers the needed biographical information about your child. The second form provides the school with emergency contact information and instructions in the event the school needs to contact someone on your child's behalf. The third form is our health form. This provides the school with information about your child's health in order to help us make QSI Shekou a fun and safe place to learn and grow.</p>
<p><strong>Remember to give the following documents to the admissions department:</strong></p>
<ul>
<li>Immunization records (copy)</li>
<li>Health / Emergency Form (Found on our Website)</li>
<li>Previous School Records (copy)</li>
<li>Student's Passport (copy)</li>
<li>Student's Visa (copy)</li>
<li>Mother's Passport (copy)</li>
<li>Mother's Visa (copy)</li>
<li>Father's Passport (copy)</li>
<li>Father's Visa (copy)</li>
<li>3 Student Passport Photos</li>
</ul>
<button class="nexttab" href="#"><strong>Let's get started!</strong></button>
</div>
<div id="tabs-2">
</div>
<div id="tabs-3">
</div>
<div id="tabs-4">
</div>
</div>
</body>
</html>
JavaScript / JQueryUI:
$(document).ready(function() {
var $tabs = $('#tabs').tabs();
$(".nexttab").click(function() {
var selected = $("#tabs").tabs("option", "selected");
$("#tabs").tabs("option", "selected", selected + 1);
});
//get selected tab
function getSelectedTabIndex() {
return $tabs.tabs('option', 'selected');
}
//get tab contents
beginTab = $("#tabs ul li:eq(" + getSelectedTabIndex() + ")").find("a");
loadTabFrame($(beginTab).attr("href"),$(beginTab).attr("rel"));
$("a.tabref").click(function() {
loadTabFrame($(this).attr("href"),$(this).attr("rel"));
});
//tab switching function
function loadTabFrame(tab, url) {
if ($(tab).find("iframe").length == 0) {
var html = [];
html.push('<div class="tabIframeWrapper">');
html.push('<div class="openout"><a href="' + url + '"><img src="data/world.png" border="0" alt="Open" title="Remove iFrame" /></a></div><iframe class="iframetab" src="' + url + '">Load Failed?</iframe>');
html.push('</div>');
$(tab).append(html.join(""));
$(tab).find("iframe").height($(window).height()-80);
}
return false;
}
});
ボタンでタブが変更されないのはなぜですか?