title: $("form").submit(function() { Not working in Firefox
body: <pre><code>    $("form").submit(function() {
          if ($("#content") != null) {
              $("#content").replaceWith('&lt;div id="page-loader" class="fade in"&gt;&lt;span class="spinner"&gt;&lt;/span&gt;&lt;span class="spinner-text center"&gt;We are running as fast as our little ninja feet can go...&lt;/span&gt;&lt;/div&gt;');
          }
          return true;
      });
  </code></pre>
  
  <p>The above works fine on Chrome but does not work on Firefox. Not sure why but in Firefox the form is not actually submitted. The div replace works but no love on the submit, the page just stays idle.</p>
  
  <p>The intent here is to capture a submit of any form and throw a spinner (CSS not an image) onto the page until the post / put is returned and the spinner is wiped out by the actual content div on the page reload (non ajax).</p>
  
  <p>Before:</p>
  
  <p><a href="https://i.stack.imgur.com/SPB0h.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/SPB0h.png" alt="Before"></a></p>
  
  <p>After:</p>
  
  <p><a href="https://i.stack.imgur.com/Eo6JW.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Eo6JW.png" alt="After"></a></p>
  
  <p>Code Removed (the post now appears):</p>
  
  <p><a href="https://i.stack.imgur.com/ghgZh.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ghgZh.png" alt="Code Removed"></a></p>
  
  <pre><code>&lt;form accept-charset="UTF-8" action="/users/sign_in" class="new_user" id="new_user" method="post" role="form"&gt;
  </code></pre>
  
  
  
  <pre><code>            &lt;!-- begin row --&gt;
              &lt;div class="row"&gt;
                  &lt;!-- begin col-12 --&gt;
                  &lt;div class="col-lg-6"&gt;
                      &lt;div class="form-group"&gt;&lt;label class="sr-only control-label" for="user_email"&gt;Email&lt;/label&gt;&lt;input autofocus="autofocus" class="form-control" id="user_email" name="user[email]" placeholder="E-mail" type="email" value="" /&gt;&lt;/div&gt;
                  &lt;/div&gt;
                  &lt;div class="col-lg-6"&gt;
                      &lt;div class="form-group"&gt;&lt;label class="sr-only control-label" for="user_password"&gt;Password&lt;/label&gt;&lt;input class="form-control" id="user_password" name="user[password]" placeholder="Password" type="password" /&gt;&lt;/div&gt;
                  &lt;/div&gt;
              &lt;/div&gt;
              &lt;!-- end row --&gt;
              &lt;!-- begin row --&gt;
              &lt;div class="row"&gt;
                  &lt;!-- begin col-12 --&gt;
                  &lt;div class="col-md-12 center"&gt;
                      &lt;/br&gt;
                  &lt;/div&gt;
              &lt;/div&gt;
              &lt;!-- end row --&gt;
              &lt;!-- begin row --&gt;
              &lt;div class="row"&gt;
                  &lt;!-- begin col-12 --&gt;
                  &lt;div class="col-md-12 center"&gt;
                      &lt;input class="btn" name="commit" type="submit" value="Sign in" /&gt;
                      &lt;div class="m-t-20"&gt;
  
  &lt;a href="/users/password/new"&gt;Forgot your password?&lt;/a&gt;&lt;br/&gt;
  
  &lt;a href="/users/confirmation/new"&gt;Didn&amp;#39;t receive confirmation instructions?&lt;/a&gt;&lt;br/&gt;
  
  &lt;a href="/users/unlock/new"&gt;Didn&amp;#39;t receive unlock instructions?&lt;/a&gt;&lt;br/&gt;
  
                      &lt;/div&gt;
                  &lt;/div&gt;
              &lt;/div&gt;
              &lt;!-- end row --&gt;
  </code></pre>
  
  <p> </p>
  
  <pre><code>&lt;script&gt;
  $(document).ready(function () {
      App.init();
  
      $("form").submit(function(){
          if ($("#content") != null) {
              $("#content").replaceWith('&lt;div id="page-loader" class="fade in"&gt;&lt;span class="spinner"&gt;&lt;/span&gt;&lt;span class="spinner-text center"&gt;We are running as fast as our little ninja feet can go...&lt;/span&gt;&lt;/div&gt;');
          }
          return true;
          alert("Submitted");
      });
  });
  
  $(function () {
      var hash = window.location.hash;
      hash &amp;&amp; $('ul.nav a[href="' + hash + '"]').tab('show');
  });
  </code></pre>
  
  <p></p>
  
  <p>UPDATE:</p>
  
  <p>Ok so i am an idiot but for some reason this didn't cross my mind. What is happening is that the #content div includes the form i am replacing. So the mystery to me is why that worked in Chrome / IE and not in Firefox? </p>
  
  <p>If i use the following it works but i get some dangling form elements:</p>
  
  <pre><code>$("form").submit(function(){
          if ($("#content") != null) {
              $("#content").append('&lt;div id="page-loader" class="fade in"&gt;&lt;span class="spinner"&gt;&lt;/span&gt;&lt;span class="spinner-text center"&gt;We are running as fast as our little ninja feet can go...&lt;/span&gt;&lt;/div&gt;');
          }
          return true;
      });
  </code></pre>