jQuery datepicker, tabs, AJAX

The whole bloody day fighting with jQuery datepicker. Still no luck, so maybe you have something to tell. The setup is as follows:

– jQuery tabs with content being loaded via AJAX calls

– Inside tabs content there are forms with jQuery datepicker

The problem is that datepicker doesn’t work correctly. There are two possible results (except for those where everything is broken completely):

– Datepicker is displayed and popup is shown, but when selecting a date – it is not inserted in the input field (though it is send correctly when form is submitted)

– Datepicker is displayed and everything works (even when selecting a date it is correctly inserted into field), but after switching between tabs for 2-3 times, datepicker is disappearing from some fields and stays enabled on others.

I tried everything I could find. Working with jQuery live, jQuery livequery, setTimeouts (for proper delay on DOM updates). Tried accessing through classes and through IDs, tried generating random IDs just in case there is a collision or something else. Nothing works :(

Pissed off, experimenting further, but looks like I am running out of possibilities…