1

For example, Having 1st Page HTML Include header Page HTML

Page 1 javascript

<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script> 
   $(function(){
     $("#header").load("Header.html");
   });
</script>
<div id="header"></div>

Header page

<a href="#" data-toggle="dropdown" class="dropdown-toggle">Booking
<span class="caret"></span></a>
<ul class="dropdown-menu">
    <li><a id="booking" href="#">New Booking</a></li>
    <li id="cancel"><a href="url">Cancellation</a></li>
    <li id="my_booking"><a href="url">My Booking</a></li>
</ul>
</li>

So my problem is, in my header page HTML I having a menu drop-down-list. During the page is loading, I am able to click the menu to drop down the list. Once the page is complete loaded to the page 1, the menu is malfunctioned and not response after I click.

Minal Chauhan
  • 6,025
  • 8
  • 21
  • 41
hiboss
  • 317
  • 6
  • 15
  • @hiboss I haven't used bootstrap in a while, is the dropdown menu implemented in pure CSS or do you also include the bootstrap javascript? – Simon Hänisch Jul 28 '16 at 12:59
  • @SimonHänisch yes pure CSS using the bootstrap javascript – hiboss Jul 28 '16 at 13:04
  • @hiboss well pure CSS means that it doesn't need javascript to work... I just checked and that is not the case (you need javascript). So I assume you include `jquery.min.js` and `bootstrap.min.js` (in that order) before your own script (the one that loads the header)? I created a fiddle and use jquery's `.html('string')` to dynamically add a menu (which is basically the same as ajax loading regarding event handlers) and it works: https://jsfiddle.net/0d033by6/1/ I can't see where your difference is without seeing more of your code – Simon Hänisch Jul 28 '16 at 13:32
  • also your `Header.html` markup is wrong: there is a closing `` at the end that doesn't belong anywhere, and more importantly it needs to be wrapped in a `` (see http://getbootstrap.com/javascript/#dropdowns) – Simon Hänisch Jul 28 '16 at 13:37