I open the bootstrap modal by clicking on a button. The modal opens and there is a input field that is hooked to datepicker. I click in the textbox and I see the calendar. I close the modal. I open the modal again, then click in the textbox, the calendar doesn't show up. Why isn't the datepicker showing up second time i open the modal and click in the textbox?

i have a partial view \_RequestAppointment with the following javascript at bottom.

```
<script>
    $(function () {

        $(".requestedAppointmentDate").datepicker();

        $('#myModal').on('hidden.bs.modal', function () {
            //alert('hello');
            //$(".requestedAppointmentDate").datepicker("destroy");
            //$(".requestedAppointmentDate").removeClass("hasDatepicker").removeAttr('id');
            $(".requestedAppointmentDate").datepicker("destroy");
        });

        $('#myModal').on('show.bs.modal', function () {
            //$('.HomeContainer').addClass('blur');
            $(".requestedAppointmentDate").datepicker({});
        })

    });
</script>

```

This is the javascript in home page. I am only showing the code relevant to the \_RequestAppointment partial view. 

```
$(function () {
    function onRequestAppt() { var url = '@Url.Action("_RequestAppointment", "Home")'; ResetModal(); LaunchModal(url); }

    function ResetModal() {      // Resets the popup
                $('body').on('hidden.bs.modal', '.modal', function () {
                    $(this).removeData('bs.modal');
                });
            }
        function LaunchModal(url) {
            $('#myModal').modal({
                remote: url,
                backdrop: 'static'
            });
        }

    $('#myModal').on('show.bs.modal', function () {
                    $('.HomeContainer').addClass('blur');
                    //$(".requestedAppointmentDate").datepicker({});
                })

                $('#myModal').on('hide.bs.modal', function () {
                    $('.HomeContainer').removeClass('blur');

                });
}

```

I have searched on google regarding this and found no solution. Please help.