I am trying to trigger an event outside of the jQuery UI's onSelect code.
I am trying to use jQuery (and I tried vanilla JS too), to catch the on select event of a date, which is actually a 'table td' element.
I tried bubbling up the event, are there any suggestions on how to capture the on select event outside of the jQuery UI date picker plugin code? I thought this should be fairly easy, but for the life of me, I can not capture it.
Here is my code:
$(function() {
$( "#datepicker" ).datepicker();
//I will not be using the onSelect inside the datepicker() function.
//I need access without adding it into the datepicker() function hence the code below
});
//This works
$('body').on("click", function(){
//console.log("body click");
});
//This does not and Why?
$('body').on("click", ".ui-datepicker-calendar td", function(){
console.log("date picked");
});
//NEITHER DOES THIS
$(".ui-datepicker-calendar td").on("click", function(){
console.log("date picked");
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>
<input id="datepicker" />
Here is my CodePen https://codepen.io/createitcarlos/pen/OJvWLpY