0

My jQuery datepicker has stopped working...it no longer shows the datepicker on click of an input field. There are no console errors.

I already checked for a solution here.

So I tried adding a new CSS style: <link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/smoothness/jquery-ui.css">

That did not help.

Another proposed solution was soo check for a duplicate occurrence of clip: rect(0 0 0 0);, but that is not the case either.

I also tried explicitly calling show() on the input field after initialization, but that does not help either.

I also inspected the HTML, but I can't find the HTML for the datepicker so I can't even see what classes are assigned and if that is messing things up.

Here's my code:

(I added a breakpoint and the .datepicker call is executed.)

<input name="ctl00$CPHCenter$tbReservationDate" type="text" maxlength="14" id="tbReservationDate" class="textbox" placeholder="Datum Reservering" style="width:80%;">

<script>
$(function () {
    $("#tbReservationDate").datepicker({ dateFormat: 'dd-mm-yy', firstDay: 1 });
    //$("#tbReservationDate").show();
});     
</script>   
2
  • Have you included jQuery before jQuery-ui? Any error in console? Commented Aug 16, 2016 at 15:14
  • I had not included jQuery before jQuery-ui...I have now (locally). Also no console errors. But still it does not work. Commented Aug 16, 2016 at 15:17

1 Answer 1

3

You have two elements in your html with id="tbReservationDate".

The first one that appears in the DOM is the one in the popup (and there the datepicker works). Change the id or use a class to initialize the datepicker.

Sign up to request clarification or add additional context in comments.

1 Comment

Exactly, I was about to answer that, anyway, html expects id attribute to be unique, that's why jQuery could not select that element. And you are completely right!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.