Repositioning Datepicker

Repositioning Datepicker


Alright, I see others have been having this similar issue, but I
haven't been able to find a good solution yet.
I'm using the datepicker and have several instances of it on a page.
My problem is that when I dynamically add content above the existing
datepicker fields (causing them to slide down) the datepicker calendar
appears in the wrong position (where it was when the page originally
loaded I assume).
I've tried removing all the instances of the datepicker when I add the
content, then readding the datepicker functionality like this:
$('img.ui-datepicker-trigger').remove();
$('input.hasDatepicker').removeAttr('id').removeClass
('hasDatepicker');
$('input.calendar').each(function() {
    $(this).datepicker({
        showOn: 'both',
        buttonImage: 'images/calendar.png',
        buttonImageOnly: true
    });
});
But that doesn't seem to work very well. In fact, all the old
datepicker fields end up showing their calendar box at the same spot
on the page. Any thoughts?