I'm displaying the datePicker when hovering over an image. The code to fire the event is as follows.
$("#calendar").on("mouseover", function (event) {
$("#calendar").datepicker("dialog", null, function (date) {
$("#departureDate").val(date);
}, options, [event.PageX, event.PageY]);
});
This works as supposed to, because the event mouseover has coordinates where it occurs. Now, I'd also like to fire the event when focusing on an input box, so I added the following code, noticing that the datePicker isn't displayed because the event is null. When I enter [0, 0] as coordinates, I get it to show but in the wrong location.
$("#departureDate").on("focus", function (event) {
$("#calendar").datepicker("dialog", null, function (date) {
$("#departureDate").val(date);
//}, options, [event.PageX, event.PageY]);
}, options, [0, 0]);
});
How can I obtain the coordinates of the control that is being focused on?
Or even wider - how can I obtain the coordinates of a control that has caused any event?