Fullcalendar Gem Rails不显示

时间:2017-10-24 15:06:45

标签: ruby-on-rails ruby rubygems

FullCalendar显示为空白如何显示日历。似乎在rails上的fullcalendar很少有指南或文档。我似乎无法确定错误的原因。没有错误只显示空白页面。

查看

<div class="calendar"></div>

通道/ full_calendar.js

var initialize_calendar;
initialize_calendar = function() {
    $('.calendar').each(function(){
        var calendar = $(this);
        calendar.fullCalender({});
    })
};
$(document).on('turbolinks:load', initialize_calendar);

Application.js

//= require jquery
//= require rails-ujs
//= require bootstrap
//= require moment
//= require fullcalendar
//= require jquery-dcjqaccordion
//= require_tree .

Application.css.scss

 *= require fullcalendar
 *= require daterangepicker

1 个答案:

答案 0 :(得分:0)

看起来你不见了

//= require turbolinks

application.js中。没有它,'turbolinks:load'将无法触发。

如果您打算使用Turbolinks,您还需要在导航前销毁您的fullCalendar对象,如mentioned here

function eventCalendar() {
  return $('#event_calendar').fullCalendar({ ***your FullCalendar config***});
};

function clearCalendar() {
  $('#event_calendar').fullCalendar('delete'); // In case delete doesn't work.
  $('#event_calendar').html('');
};

$(document).on('turbolinks:load', eventCalendar);
$(document).on('turbolinks:before-cache', clearCalendar)