简体   繁体   English

Jquery加载的Foundation Tabs /内容

[英]Foundation Tabs/content loaded with Jquery

I'm using Foundation 6. I have a select that when you select something it loads the info on the right of it. 我使用的是Foundation6。我有一个选择,当您选择某些内容时,它将在其右侧加载信息。 Everything loads as expected. 一切都按预期加载。 The problem being that the tabs don't switch. 问题在于选项卡不会切换。 Everything is loaded correctly but it just doesn't tab over. 一切都已正确加载,但只是没有结束。 Here is an example. 这是一个例子。

function showUser(str) {
    if (str == "") {
        document.getElementById("txtHint").innerHTML = "";
        return;
    } else { 
        if (window.XMLHttpRequest) {
            // code for IE7+, Firefox, Chrome, Opera, Safari
            xmlhttp = new XMLHttpRequest();
        } else {
            // code for IE6, IE5
            xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        }
        xmlhttp.onreadystatechange = function() {
            if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
                document.getElementById("txtHint").innerHTML = xmlhttp.responseText;
            }
        };
        xmlhttp.open("GET","getuser.php?q="+str,true);
        xmlhttp.send();
    }
}

php page- php页面

<div>content</div>
<div>content</div>

<ul class="tabs" data-tabs id="example-tabs">
  <li class="tabs-title is-active"><a href="#panel4" aria-selected="true">Info</a></li>
  <li class="tabs-title"><a href="#panel1">2013</a></li>
  <li class="tabs-title"><a href="#panel2">2014</a></li>
  <li class="tabs-title"><a href="#panel3">2015</a></li>
</ul>

<div class="tabs-content" data-tabs-content="example-tabs">
 <div class="tabs-panel" id="panel1">
   STUFF
 </div>
 <div class="tabs-panel" id="panel2">
   STUFF
 </div>
 <div class="tabs-panel" id="panel3">
   STUFF
 </div>
 <div class="tabs-panel is-active" id="panel4">
   STUFF
 </div>
</div>

Main page - 主页 -

<div class="large-10 columns" id="txtHint">
</div>

They just don't seem to load even though the ids are loaded correctly. 即使id已正确加载,它们似乎也似乎没有加载。

Looks like this was largely answered by @Yass in the comments, so I will address some ways that you might trouble shoot this in general. 看起来@Yass的评论在很大程度上回答了这个问题,因此,我将介绍一些可能会令您难以解决的问题。

When you are using a JS component in ZURB Foundation (annotated with a JS in the Docs) and you don't see the correct behavior, here are some good ways to troubleshoot. 当您在ZURB Foundation中使用JS组件(在文档中用JS注释)时,您看不到正确的行为,这里有一些解决问题的好方法。

1) Add the boilerplate example from the ZURB Foundation Docs that is most similar to what you are trying to do. 1)从ZURB Foundation Docs添加最类似于您尝试执行的样板示例。 In this case, one of the tab examples. 在这种情况下,选项卡示例之一。

Does it work? 它行得通吗? If so then the error is mostly likely in the structure of your html. 如果是这样,则该错误很可能是您的html结构中的错误。 Missing tags, missing attributes, misspelled tags or attributes, non-closed tags, non-closed quotes, the usual suspects. 缺少标签,缺少属性,拼写错误的标签或属性,未关闭的标签,未关闭的引号,通常的可疑字符。

If not... 如果不...

2) Check to see if jQuery is running . 2)检查jQuery是否正在运行

once running... 一旦运行...

3) Check to see if you can instantiate ZURB Foundation. 3)检查是否可以实例化ZURB Foundation。 Type the following into the JS console. 在JS控制台中输入以下内容。

$(document).foundation();

Does your JS component work correctly? 您的JS组件工作正常吗? If so, then you need make sure you instantiate ZF. 如果是这样,则需要确保实例化ZF。 This is commonly done in the app.js or application.js file that is linked in the default project. 这通常是在默认项目中链接的app.js或application.js文件中完成的。 You can also do this with a script tag after you load jQuery and ZURB Foundation (in that order). 您也可以在加载jQuery和ZURB Foundation之后(按此顺序)使用脚本标签执行此操作。

If not, then you likely have not loaded the proper ZURB Foundation JavaScript files. 如果不是,则您可能尚未加载正确的ZURB Foundation JavaScript文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM