Monday, May 20, 2024
175
rated 0 times [  177] [ 2]  / answers: 1 / hits: 22768  / 9 Years ago, thu, april 9, 2015, 12:00:00

I've been learning Ruby over the last year and I'm very new to JS so I'll try to explain this as best I can.



I am using Adam Shaw's full calendar plugin. All I want to do is get the current month I am viewing (and use that to limit how far in the future or past a user can navigate, but that's not the problem).



I can get the current date, sort of. But, because of my lack of JS knowledge I'm not sure how to access the date.



Here is the relevant section of the config file,



viewRender: function(view){
var maxDate = <%= finish.strftime('%Y/%m/%d') %>;
var currentDate = $('#calendar').fullCalendar('getDate');
console.log(currentDate);
if (view.start > maxDate){
header.disableButton('prev');

}
}


When I inspect the console log I see this being output as I click through the months.



console



So as you can see it is displaying the current date in view. My question is how do I access the _d bit of the Moment variable so I can use it?



My understanding would be that the Moment is class instance and the stuff in the dropdown is like its attributes, would this be a correct interpretation?


More From » fullcalendar

 Answers
6

FullCalendar's getDate returns a moment object, so you need moment's toDate() method to get date out of it.



So, in you code try:



console.log(currentDate.toDate());


and that should return a date object.


[#67131] Wednesday, April 8, 2015, 9 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
tristab

Total Points: 735
Total Questions: 106
Total Answers: 96

Location: Grenada
Member since Sun, Dec 20, 2020
3 Years ago
tristab questions
Sat, Sep 25, 21, 00:00, 3 Years ago
Sun, Jan 31, 21, 00:00, 3 Years ago
Wed, Dec 2, 20, 00:00, 4 Years ago
Fri, Oct 23, 20, 00:00, 4 Years ago
;