title: Multiple handlers: jQuery $(document).on
body: <p>Is it only allowed to bind 1 event to 1 thing? What I mean is, that I have 2 js files I want to initialize on the same page load.
  So I have tried the following:</p>
  
  <p>js1 / Mapmode.js:</p>
  
  <pre><code>$(document).ready(function () { initMapModeContent() });
  
  function initMapModeContent(){
      alert('test');
      initPageHeader();
      var oldHTML = document.getElementById('mapmodeContent').innerHTML;
      var newHTML = oldHTML + '&lt;div&gt;&lt;a href="pages/Beskeder.jsp#beskeder" id="mapLink" name="mapLink"&gt;&lt;img id="mapLinkImage" alt="a map which links to the beskeder" src="images/beskeder.png"/&gt;&lt;/a&gt;&lt;/div&gt;';
      document.getElementById("mapmodeContent").innerHTML=newHTML;
  }   
  </code></pre>
  
  <p>js2 / PageHeader.js: </p>
  
  <pre><code>$(document).on("pageinit", "#mapmode", function(event) {
          initPageHeader();
      });
      $(document).on("pageinit", "#beskeder", function(event) {
          initPageHeader();
      });
  
      function initPageHeader() {
          var id = document.getElementById('header').parentNode.id;
          //TODO getdata with the id(page we are currently on).
          $("#header").html(function(index, originalMarkup) {
              return '&lt;a data-theme="a" data-wrapperels="span" data-iconshadow="true" data-shadow="true" ' + 'data-corners="true" class="ui-btn-left ui-btn ui-btn-up-a ui-shadow ui-btn-corner-all" href="#" ' + 'data-rel="back" data-role="button"&gt;&lt;span class="ui-btn-inner ui-btn-corner-all"&gt;&lt;span class="ui-btn-text"&gt;' + '&lt;img src="../images/back.png" alt="back" align="middle" vspace="2"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;' + '&lt;h1 aria-level="1" role="heading" class="ui-title"&gt;' + '&lt;img src="../images/main_header.png" alt="logo" align="middle" vspace="2"&gt;' + '&lt;/h1&gt;&lt;a data-theme="a" data-wrapperels="span" data-iconshadow="true" data-shadow="true"' + 'data-corners="true" class="ui-btn-right ui-btn ui-btn-up-a ui-btn-inline ui-shadow ui-btn-corner-all" ' + 'href="#first" data-role="button" data-inline="true"&gt;&lt;span class="ui-btn-inner ui-btn-corner-all"&gt;' + '&lt;span class="ui-btn-text"&gt;' + '&lt;img src="../images/home.png" alt="picture to take you to the first page" align="middle"&gt;' + '&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;';
          });
      }
  </code></pre>
  
  <p>html5:</p>
  
  <pre><code>&lt;%-- 
      Document   : mapMode
      Created on : Jul 12, 2012, 10:36:22 AM
      Author     : ame
  --%&gt;
  
  &lt;!DOCTYPE html&gt; 
  &lt;html&gt;
      &lt;head&gt; 
          &lt;title&gt;Map&lt;/title&gt; 
          &lt;meta name="viewport" content="width=device-width, initial-scale=1"&gt; 
          &lt;link rel="stylesheet" href="js/jquery.mobile-1.1.0.css" /&gt;
      &lt;/head&gt; 
      &lt;body&gt; 
          &lt;!-- Start of first page --&gt;
          &lt;div data-role="page" id="mapmode" name="mapmode"&gt;
  
              &lt;div data-role="header" id="header" name="header"&gt;
  
                                  &lt;p&gt;TEEEST&lt;/p&gt;
              &lt;/div&gt;&lt;!-- /header --&gt;
  
              &lt;div data-role="content" id="mapmodePageContent" name="mapmodePageContent"&gt; 
                  &lt;p&gt;I'm the first page in mapMode!.&lt;/p&gt;      
  
              &lt;/div&gt;&lt;!-- /content --&gt;
          &lt;/div&gt;&lt;!-- /page --&gt;
  
  
  
          &lt;script type="text/javascript" src="../js/jquery-1.7.2.js"&gt;&lt;/script&gt;
          &lt;script type="text/javascript" src="../js/jquery.mobile-1.1.0.js"&gt;&lt;/script&gt;
          &lt;script type="text/javascript" src="../js/Mapmode.js"&gt;&lt;/script&gt;
          &lt;script type="text/javascript" src="../js/PageHeader.js"&gt;&lt;/script&gt;
  
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>I just can't find in documentation that it shouldn't work? any suggestions for how it can be made, if it is not legal, or anyone that can spot my error. </p>
  
  <p>It works in PageHeader.js but not in Mapmode.js, which is why I ask this.</p>