title: jQuery: (live) scroll Event handler on dynamically added element? How else should I solve this
body: <p>I got a (dynamically added) element that repositions based on horizontal scrolling, meaning it can go offscreen. Attached to that element, there is another one which may not go offscreen, it has to stay onscreen. So my idea was to use an event handler which asks for the elements position whenever you scroll. If the position-left attribute gets below a certain number, the attached element will then reposition.</p>
  
  <p>You know these kind of elements, it's like a menu/navigation that scrolls with you up to a certain point and then appears to be position-fixed.</p>
  
  <p>I tried this, but it's not working, probably because the elements are added with javascript. I tried <code>live("scroll"..</code> aswell, but that didn't work either.</p>
  
  <pre><code>$(window).scroll(function(ev) { 
  alert($("#scrElem").position().left);
    alert("work");    
    if ($("#scrElem").position().left &gt;= 203) {
        $("#scrElem .attElem").css("left", ($("#scrElem").position().left - 203) + "px");
      };
  });
  </code></pre>
  
  <p><strong>EDIT:</strong></p>
  
  <p>Maybe this helps:
  I'm using the tinyscrollbar plugin, here is a readable version of it ( <a href="http://baijs.nl/tinyscrollbar/js/jquery.tinyscrollbar.js" rel="nofollow">http://baijs.nl/tinyscrollbar/js/jquery.tinyscrollbar.js</a> ). Basically this plugin is firing events when scrolled. That's what I want, I even saw where he did it:</p>
  
  <pre><code>oWrapper[0].addEventListener( 'DOMMouseScroll', wheel, false );
  oWrapper[0].addEventListener( 'mousewheel', wheel, false );
  oWrapper[0].addEventListener( 'MozMousePixelScroll', function( event ){
    event.preventDefault();
  }, false);
  </code></pre>