title: Is my Twitter Bootstrap's ScrollSpy trying to spy elements not supposed to be spied?
body: <p>I'm using BackboneJS and Bootstrap, and I was trying to enable scroll spy on some content after the visitor clicks on a button.</p>
  
  <p>So when the user clicks on that button, these gets executed:</p>
  
  <pre><code>$('#frontPageNav').css('display', 'block'); // It was hidden on load
  $('#frontPageNav').scrollspy(); // Activate scrollspy, this is where the error happens
  $('[data-spy="scroll"]').each(function () {
    var $spy = $(this).scrollspy('refresh'); // I think this is not needed because nothing was invisible before
  });
  $('#frontPageNav li').on('activate', function () { // This never gets emitted
    alert('activate!');
  });
  </code></pre>
  
  <p>And the content I'd like to be spied is placed like this:</p>
  
  <pre><code>&lt;div data-spy="scroll" data-target="#frontPageNav"&gt;
    &lt;div id="home-top" class="row slide"&gt;
    &lt;/div&gt;
    &lt;div id="home-how" class="row slide"&gt;
    &lt;/div&gt;
    &lt;div id="home-join" class="row slide"&gt;
    &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>No other element on the page has the data-spy attribute, so I think this is supposed to be the only content spied, but apparently not: On page load I get an error, <code>Uncaught TypeError: Cannot read property 'top' of null</code>, which means the scrollspy plugin is attempting to find the <code>$.position()</code> of an element that does not exist. I turned on the exception brakes in Chrome's developer tools, and the uncaught exception is in line 454 of bootstrap.js, which is <code>&amp;&amp; [[$href.position().top, href]]) || null</code> and if I hover <code>href</code>, the selector is for an element that I don't have in my markup, but I have a link to a hash with that.</p>
  
  <p>Does this mean that the scrollspy plugin thinks it's supposed to spy all links with <code>href="#something"</code> and find in the markup elements with that ID ? Why isn't it keeping the spying action to the elements with <code>data-spy="scroll"</code> ?</p>