Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jquery UI dialog scroll follow?

How is it possible for a jquery UI dialog to follow window scroll ?

like image 662
RoseWarad Avatar asked Jan 20 '26 12:01

RoseWarad


1 Answers

It is possible but you need to override the base jQueryUI styles, so make sure (in your CSS) you have:

.ui-dialog {
    position: fixed !important;
}

Here is an example:

$(function() {
  $("#dialog-modal").dialog({
    height: 140,
    modal: true
  });
});
body {
  height: 3000px;
  }

p {
  margin-bottom: 300px;
  }

.ui-dialog {
  position: fixed !important;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<link href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" rel="stylesheet" />
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>


<div id="dialog-modal" title="Basic modal dialog">
  <p>Adding the modal overlay screen makes the dialog look more prominent because it dims out the page content.</p>
</div>


<!--these are here to help show that the dialogue is actually fixed -->
<p>A</p>
<p>B</p>
<p>C</p>
<p>D</p>
<p>E</p>
<p>F</p>
like image 162
Chris Spittles Avatar answered Jan 22 '26 05:01

Chris Spittles



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!