vkurko/calendar

Cant get dateClick value

AdrianGzzEsc opened this issue · 9 comments

I dont know in which version but before, every time I click on an event the onDateClick also triggered and now it doesn't. Understandable but now I cant get what date he click on from the on eventClick data. If an event lasts a week I need to know which date he click on

Yes, this behavior has been fixed in version 0.14.0. This was supposed to make it easier for applications that use clicking on an event to view/edit it, and clicking on free space to create a new event.

May I know the details of your case? Why do you need to know the exact date even when clicking on an event?

I use this calendar for a fabrics production plan. The events are production tasks, for example 500 pieces of model A most be done on Feb 14. If they don't report the production the task automatically expands to next day to display it as a production delay. To report production they click ok the event and report how many they did. Sometimes a task from friday expands to monday because they didnt report it and I will like them to be able to click the event on friday to know thats the actual day they finish the production and fix itself. I got it working on day view but cant on the month one

image

image

Thanks for the explanation. I'll try to provide some solution.

The research curve led me to this FullCalendar issue.

It seems that other users had a very similar situation to yours and the solution was to provide a method that would allow them to get the date and time for any point inside the calendar, knowing its coordinates. You have these coordinates inside the eventClick callback.

Apparently FullCalendar has not yet implemented such a method. So I made it in Event Calendar, and it is available since version 0.16.0.

Please check dateFromPoint.

For anyone else needing this, I created this function which will give me the day picked when selecting the event. It looks for the events start date and then based on your mouse position and the width of the ec-day element it can find the right day you where selecting

var datePicked $(document).on("mousedown", ".ec-event", function (e) { var day = parseInt($(this).closest('.ec-day').find('.ec-day-head').text()) var offset = $(this).offset() var width = $(this).closest('.ec-day').width() datePicked = day + Math.floor((e.pageX - offset.left) / width) })

@AdrianGzzEsc did you try dateFromPoint? This function should return exactly what you need.

eventClick: function (info) {

    let datePicked = ec.dateFromPoint(info.jsEvent.clientX, info.jsEvent.clientY);

}

Oh man I thought you said that I had to create the method based on the mouse coordinates. Didn't saw you edit it and added dateFromClick, but yeah I just tried it and works perfect

Well I just notice some errors, I gotta stick to my method. Since I have overflow, when selecting an event below the initial view it messes up. It was giving me a date from 1970

Since I have overflow

Yes, overflow inside calendar cells in general is not supported.

In any case, the implemented dateFromPoint method will be useful to other users in similar situations.