I am working on a ASP.Net webform which includes AJAX Modelpoup Extender
and jquery nepali-datepicker
. I have to integrate nepali-datepicker
to a textbox that is inside my second modelpopup
i.e. with blue background shown in image below.
Problem I am facing is that I am not able to position datepicker
at bottom of textbox
Based on answers on the post(How to change the pop-up position of the jQuery DatePicker control) I was able to bring datepicker in front of 2nd model popup. Is there a way that I can use to actually position datepicker to the textbox.
Here is my script and styles:
<script type="text/javascript">
function pageLoad() {
$('.nepali-calendar').nepaliDatePicker();
}
$(document).ready(function () {
$('.nepali-calendar').nepaliDatePicker();
});
</script>
<style type="text/css">
div#ndp-nepali-box
{
position:absolute;
z-index: 999999;
}
</style>
Following image shows how it is is positioned right now.
If I use position
as relative
.
<style type="text/css">
div#ndp-nepali-box
{
position: relative;
z-index: 999999;
}
</style>
It looks like
Is there a way that I can use to actually position datepicker to bottom of the textbox.
In the same way we can set the position of the popup where ever needed just by setting “marginTop” and “marginLeft” attributes. Here beforeShow () is the method exposed by datepicker widget.
To change the position of the jQuery UI Datepicker just modify .ui-datepicker in the css file. The size of the Datepicker can also be changed in this way, just adjust the font size. @gfrizzle - yep, that answer of mine was just so wrong.
Open the modal and click on the input field. The datepicker will pop up. Now scroll the page. You will see that the datepicker doesn't scroll with the page – it just stays at the exact position where it was placed at the beginning. Sorry, something went wrong.
But the default popup position is just below the text box so we had to work around to make it appear at the side.. The following code block in document.ready method demonstrates the hack: In the same way we can set the position of the popup where ever needed just by setting “marginTop” and “marginLeft” attributes.
As you are using jquery UI Datepicker
it should have beforeShow
property and change css inside this property like below.
Check this fiddle
$('input.date').datepicker({
beforeShow: function(input, inst) {
var cal = inst.dpDiv;
var top = $(this).offset().top + $(this).outerHeight();
var left = $(this).offset().left;
setTimeout(function() {
cal.css({
'top' : top,
'left': left
});
}, 10);
}
});
Reference
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With