Conflict between jquery and bootstrap

css, javascript, jquery, php, twitter-bootstrap

Solution

data-toggle="tab" for bootstrap means there has to have a [tab panel] for it, however, you only use it as nav, and it caused the problem.

Please read: http://getbootstrap.com/javascript/#tabs

Also, use js closure can more easier to avoid js conflict issue:

(function($){
    ....
})(jQuery);

Please check the code below, you can use WinMerge to compare the code with your own:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<!--<style>{height:150px; width:1300px;}</style>-->
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<META HTTP-EQUIV="CACHE-CONTROL" CONTENT="Public">
<title><?php echo $page_title ?></title>
<script src="http://code.jquery.com/jquery-1.10.2.min.js" type="text/javascript"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.min.js" type="text/javascript"></script>
<link href="//netdna.bootstrapcdn.com/bootstrap/3.1.0/css/bootstrap.min.css" rel="stylesheet">
<!--<link href="css/style_header.css" rel="stylesheet">-->
</head>
<body>
<div class="container">
        <div class="row clearfix">
                <div class="col-md-4 column">
                </div>
                <div class="col-md-8 column dbf">
                        <h2>
                                DBA Factory
                        </h2>
                </div>
        </div>
        <div class="row clearfix">
                <div class="col-md-12 column">
                        <div class="tabbable" id="tabs-775712">
                                <ul class="nav nav-tabs">
                                         <li>
                                                <a href="#panel-4">Home</a>
                                        </li>
                                        <li>
                                                <a href="#panel-4">Submit a project</a>
                                        </li>
                                        <li>
                                                <a href="#panel-4">All Projects</a>
                                        </li>
                                        <li>
                                                <a href="#panel-4">Innovative Ideas</a>
                                        </li>
                                        <li>
                                                <a href="#panel-5">Matchmaker</a>
                                        </li>
                                        <li>
                                                <a href="#panel-6">Meet the Team</a>
                                        </li>

                                        <li class="dropdown">
                                            <a id="userlogin" role="button" data-toggle="dropdown" href="#">rdesai<span class="caret"</span></a>

                                            <ul class="dropdown-menu" role="menu" aria-labelledby="userlogin">
                                                <li role="presentation"><a role="menuitem" tabindex="-1" href="#">Settings</a></li>
                                            </ul>
                                        </li>
                                </ul>

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


</div>
<script type="text/javascript" src="//netdna.bootstrapcdn.com/bootstrap/3.1.0/js/bootstrap.min.js"></script>
<script>
(function($){

    $(document).ready(function (){
            $('.dropdown-toggle').dropdown();
            $('#userlogin').dropdown('toggle');
    });

})(jQuery);
</script>
</body>
</html>

Problem

I have a code where I am including jquery files and bootstrap files in the header.php. I am running into issues where if I include the jquery file before bootstrap.js file, it messes up the other tabs on my webpage and basically even if i click on the other tabs it does not navigate me. I think there is a conflict between jquery and bootstrap. I am pasting my header.php file below for more reference. header.php ``` <?php require_once "essentials.php"; //error_reporting(~0); //ini_set('display_errors', 1); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <!--<style>{height:150px; width:1300px;}</style>--> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <META HTTP-EQUIV="CACHE-CONTROL" CONTENT="Public"> <title><?php echo $page_title?></title> <script src="http://code.jquery.com/jquery-1.10.2.min.js" type="text/javascript"></script> <script src="http://code.jquery.com/ui/1.10.3/jquery-ui.min.js" type="text/javascript"></script> <script type="text/javascript" src="js/bootstrap.js"></script> <script src="script_dbafactory.js?<?php echo rand(0,511);?>"></script> <link href="css/bootstrap.css" rel="stylesheet"> <!--<link href="css/style_header.css" rel="stylesheet">--> </head> <body> <div class="container"> <div class="row clearfix"> <div class="col-md-4 column"> <img alt="logo" src="./images/source.png"> </div> <div class="col-md-8 column dbf"> <h2> DBA Factory </h2> </div> </div> <div class="row clearfix"> <div class="col-md-12 column"> <div class="tabbable" id="tabs-775712"> <ul class="nav nav-tabs"> <li> <a href="../dbafactory/home_page.php?sub=1" data-toggle="tab">Home</a> </li> <li> <a href="../dbafactory/form_page.php?sub=2" data-toggle="tab">Submit a project</a> </li> <li> <a href="../dbafactory/view_table.php?sub=3" data-toggle="tab">All Projects</a> </li> <li> <a href="#panel-4" data-toggle="tab">Innovative Ideas</a> </li> <li> <a href="#panel-5" data-toggle="tab">Matchmaker</a> </li> <li> <a href="#panel-6" data-toggle="tab">Meet the Team</a> </li> <div class="dropdown"> <?php include "userlogin.php"; ?> </div> </ul> </div> </div> </div> </div> </body> <!--<script type="text/javascript"> //Script to implement tabs $('#myTab a').click(function (e) { e.preventDefault() $(this).tab('show') }) </script>--> <script> $.noConflict(); $(document).ready(function (){ $('.dropdown-toggle').dropdown(); $('#userlogin').dropdown('toggle'); }); </script> ``` Can someone please let me know how do i solve this issue? and how should i load all the js and css files to avoid any issues with the webpage. Thanks

Original source