0

I use a jQuery DateTimePicker in many places in my web app. It works fine everywhere exept in one place where the calendar just won't pop up. Here's the source code of the page (view in Chrome).

<script>
    $('#example9').datetimepicker({ timeFormat: 'h:mm', stepMinute: 5, dateFormat: 'yy-mm-dd'
</script>

<div>
    <input type="text" name="example9" id="example9" value="2012-10-16 15:00" />
</div>

As you can see, I've reduced the code to the simplest and added an event listener. Nothing is triggered and nothing happens whenever I click the input.

Any clue?

Mathieu
  • 4,449
  • 7
  • 41
  • 60

3 Answers3

1

Why would you do it that way? Instead of calling the datepicker on each specific input based on ID, just create an HTML class that all datepicker inputs will have. Then in your _Layout, or other JavaScript file that always gets called, turn everything with that class into a DatePicker.

krillgar
  • 12,596
  • 6
  • 50
  • 86
1

Make sure

  1. jQuery and your plugin are loaded.
  2. your script is run after the DOM is loaded (or at least after the used element is rendered). So move your script code after the div element, or use $(document).ready(function(){/*your-code*/});
  3. the id is unique in the html or it will fail.
Gabriele Petrioli
  • 191,379
  • 34
  • 261
  • 317
0

You are doing this

.data("events")

I do not see a data-events attribute for the textbox

Sushanth --
  • 55,259
  • 9
  • 66
  • 105