title: Dynamically change the location of the popover depending upon where it displays
body: <p>I'd like to dynamically change the popover placement (left/right, top/bottom) depending on where the element is located on the screen.</p>
  
  <pre class="lang-js prettyprint-override"><code>//get_popover_placement(dom_el) returns 'left', 'right', 'top', or 'bottom'
      function set_popover(dom_el) {
      var the_placement = get_popover_placement(dom_el);
      $(dom_el).popover({
          offset: 10,
          placement: the_placement
      }).popover('show');
  }
  
  //set the placement on every hover
  $('a[data-rel=popover]').hover(function(){
          set_popover(this);
      }, function(){});
  </code></pre>
  
  <p>It works the first time, but if the position of the element changes (when the window is resized, for example), the placement is not updated with subsequent calls to set_popover.</p>
  
  <p>I added a little bit of code to get_popover_placement that adds a different color border to the element, depending on the placement.  The border color gets updated every time, indicating the code is being called and the calculations are being done correctly, but the placement does not get updated.</p>
  
  <p>It appears as though the placement option can only be set one time.  How can I get around this limitation?  Is there a variable somewhere that can be cleared to reset popovers?</p>