5

I want to run the fullcalendar on my rails project. I am following the steps in https://github.com/bokmann/fullcalendar-rails but I am having an error.

the calendar only shows properly as in this view http://fullcalendar.io/js/fullcalendar-2.2.6/demos/basic-views.html when I call everything from my application.html.erb page like this

<!DOCTYPE html>
<html>
<head>

  <title>LetsScheduleComMy</title>
  <%= csrf_meta_tags %>
  <meta charset='utf-8' />
  <meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible" />
  <meta name="apple-mobile-web-app-capable" content="yes" /> 
  <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1">
  <meta content="05DB4EB1125C9BB77659AD0ADC8E0BAC" name="msvalidate.01">
    <link href='/assets/fullcalendar.css' rel='stylesheet' />
    <link href='/assets/fullcalendar.print.css' rel='stylesheet' media='print' />
    <script src='/assets/moment.min.js'></script>
    <script src='/assets/jquery.min.js'></script>
    <script src='/assets/fullcalendar.min.js'></script>
    <script>
        $(function() {
    $('#calendar').fullCalendar({
        header: {
            left: 'prev,next today',
            center: 'title',
            right: 'month,agendaWeek,agendaDay'
        }

    });
});
    </script>
</head>
<body>  
<%= yield %>

</body>
</html>

But whenever i try to make it dynamic rails way, it doesnt run properly. So in my application.js file

//= require jquery
//= require moment.min
//= require jquery.min
//= require fullcalendar.min
//= require_tree .

and in my application.css.scss file

 *= require_tree 
 *= require_self

and in my application.html.erb file

<!DOCTYPE html>
<html>
<head>
  <title>LetsScheduleComMy</title>
  <%= stylesheet_link_tag    'application', media: 'all'%>
  <%= javascript_include_tag 'application'%>
  <%= csrf_meta_tags %>
  <meta charset='utf-8' />
  <meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible" />
  <meta name="apple-mobile-web-app-capable" content="yes" /> 
  <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1">
  <meta content="05DB4EB1125C9BB77659AD0ADC8E0BAC" name="msvalidate.01">

    <script>
        $(function() {
    $('#calendar').fullCalendar({
        header: {
            left: 'prev,next today',
            center: 'title',
            right: 'month,agendaWeek,agendaDay'
        }

    });
});
    </script>
</head>
<body>  
<%= yield %>

</body>
</html>

Kindly note that the only difference here is i have put the required css and javascript files in my application.js and application.css files and added the javascript nd stylesheets tags in my application.html.erb file as recommended by rails. But then it seems fullcalendar doesnt accept rails way of implementation.

Is there anything that can be done?

Thanks

Kingsley Simon
  • 2,090
  • 5
  • 38
  • 84
  • what version of fullcalendar? – warath-coder Jan 28 '15 at 18:04
  • also, have you checked that the rendered page has all the correct javascript files loaded in order required. – warath-coder Jan 28 '15 at 18:05
  • i think its a fullcalendar rails bug because when i add <%#= stylesheet_link_tag 'application', media: 'all'%> <%#= javascript_include_tag 'application'%> it doesnt show properly but when i comment them out then it rund properly but that is very inefficient as i have already added necessary javascripts nd css files for fullcalendar in my application.css and application.js and i cant run rails without these two tags in my application.html.erb page. – Kingsley Simon Jan 31 '15 at 04:01
  • again; when you load the page on a web browser, click on 'view source' and make sure that all the proper files have been loaded (or use firefox/firebug). – warath-coder Jan 31 '15 at 13:18
  • all files have been loaded properly. – Kingsley Simon Feb 02 '15 at 02:09

1 Answers1

15

Try removing fullcalendar.print.css... it fixed the issue for me.

Matt
  • 74,352
  • 26
  • 153
  • 180
  • Do you know why removing the print stylesheet helped? – RJHunter Jul 29 '15 at 07:07
  • the css file sets the display to none on both 'fc-button-group' and 'fc button' classes to remove buttons on the calendar to be print friendly. After further testing, I realised I could keep the print.css file but change the order of loading fullcalendar.css after print.css, rather than before. This may have something to do with when the calendar is initiated. I load my scripts and styles when the page is rendered, but only initiate the calendar later after certain button clicks. – Michael Andreasen Jul 29 '15 at 15:49
  • @MichaelAndreasen Thank you a lot! – bir_ham Nov 18 '16 at 10:41
  • Thanks @MichaelAndreasen – Lim Socheat May 26 '17 at 08:37