0

I have the following example here http://jsfiddle.net/209t0drp/
where a datepicker is used on a dialog.

Both, the page and the dialog, have a scroll. Using some examples here on stackoverflow, I managed to fix the dialog while scrolling the page, but now, when I scroll the dialog's content, I would like the datepicker to move with the dialog's content, as it is part of that section.

Any idea how I can do that?

/*/////// CSS */
body{font-size:12px;}
.fixed-dialog{
  position: fixed;
  top: 150px;
  left: 50px;
}
#container { height: 5000px; }

/*/////// JS */
$(document).ready(function(){

  $('.btnOpenDialog').button().click(function(){  
      $('html, body').scrollTop(0);
      $( ".selector").dialog({ dialogClass:'fixed-dialog',modal:true});

      setTimeout("$('#dt1').focus()",100);
  });
  $('.dt').datepicker();
});

/*/////// HTML */
<div id="container">
    <div style='height:1000px'>
        <div class=filler></div>
        <br><br><span class=btnOpenDialog>Open Dialog</span>   
        <div class=filler></div>
    </div>

    <div class="selector">  <div style='height:200px;'>
        Test: <input type=text>
        <br>Date Two: <input class=dt type=text id=dt1 name=dt1 />
        <div class=filler></div>
    </div>
</div>
2
  • Why would you need to? if they aren't focused on that date input since they are scrolling, why is it bad that it disappears out of the way, as intended?
    – M.Bush
    Commented Oct 9, 2015 at 18:47
  • If you use the mousewheel to scroll, the datepicker does not disappear. It would be fine if it would disappear, but it would be much better it it would move with the content.
    – leoinfo
    Commented Oct 9, 2015 at 18:52

0