简体   繁体   English

取消包含php文件

[英]Un-include php file

I am using nav-tabs with tab-content from bootstrap. 我正在使用带有来自引导程序的选项卡内容的导航选项卡。

For each tab I said include_once('some_file.php'); 对于每个标签,我都说include_once('some_file.php');

That file get database info and it contains something that require my jquery code to work. 该文件获取数据库信息,其中包含需要我的jquery代码才能工作的内容。

Now, it works when I am on first tab but when I open second and by that include one more file with same content that require my jquery code on click on that content the content opens up in first div not in second. 现在,当我在第一个选项卡上但在我打开第二个选项卡时,它可以正常工作,并在其中包含一个具有相同内容的文件,该文件要求在单击该内容时需要我的jquery代码,该内容才会在第一个div中打开而不是第二个中打开。

If you understand what am I talking about. 如果您了解我在说什么。

I am wondering is there way to un-include included files while tab isn't active but by php? 我想知道有没有办法在选项卡未激活但通过php取消包含文件的包含?

Other solution is to for each tab make different jquery code on same way and change content for each tab which is a lot of code. 另一种解决方案是为每个选项卡以相同的方式制作不同的jquery代码,并更改每个选项卡的内容,这是很多代码。

I made JS FIDDLE where you can try to open tab2 called photos and click on text under "click here" and nothing will happen but after that click on the first tab and the content will be showed as appeared. 我制作了JS FIDDLE,您可以在其中尝试打开名为photo的tab2,然后单击“单击此处”下的文本,然后什么都不会发生,但是在单击第一个选项卡之后,内容将显示为已出现。

JSFIDDLE CHECK PLEASE JSFIDDLE检查请

<ul class="nav nav-tabs">
    <li class="active"><a data-toggle="tab" href="#all">All</a></li>
    <li><a data-toggle="tab" href="#p">Photos</a></li>

  </ul>
<div class="tab-content">
   <div id="all" class="tab-pane fade in active"><p class="ch">
     Click here
     </p>
     <div id="open" style="background: rgba(0,0,0,.4); position:fixed; width: 100%; height:100%; top:0; left:0; display:none;">

     </div>
   </div>


    <div id="p" class="tab-pane fade"> <p class="ch">
     Click here
     </p>
   <div id="open" style="background: rgba(0,0,0,.4); position:fixed; width: 100%; height:100%; top:0; left:0; display:none;">

     </div>


  </div>
  </div>
$(document).ready(function(){

$('.ch').click(function(){

    $("#open").css("display","");

});

});

ID should be unique in a DOM . ID在DOM中应该是唯一的。 "fade active in " will be added to every tab content div to switch/navigate between tabs .. if you customize default behaviour you have to manually write code to add active classes “ fade active in”将添加到每个选项卡内容div中,以在选项卡之间切换/导航..如果自定义默认行为,则必须手动编写代码以添加活动类

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

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