Carlos Uriel Santiago Carlos Uriel Santiago - 2 months ago 10
Javascript Question

fullcalendar_rails put more information on Agenda

I have the following problem just put me the title of the event and the date , but I need you to show me more fields.

if I change the index.json.jbuilder and put it in this way :( json.title event.user.email) instead of the title show me the mail appears , but I need you to show me the :user, :title , :sala, :materia.

_event.json.jbuider

date_format = event.all_day_event? ? '%Y-%m-%d' : '%Y-%m-%dT%H:%M:%S'
json.extract! event, :id, :title, :sala, :materia, :user_id

json.start event.start.strftime(date_format)
json.end event.end.strftime(date_format)

json.color event.color unless event.color.blank?
json.allDay event.all_day_event? ? true : false

json.update_url event_path(event, method: :patch)
json.edit_url edit_event_path(event)


_index.json.jbuider

json.array! @events do |event|
json.extract! event, :id, :title, :sala, :materia, :user_id
date_format = event.all_day_event? ? '%Y-%m-%d' : '%Y-%m-%dT%H:%M:%S'


json.start event.start.strftime(date_format)
json.end event.end.strftime(date_format)
json.color event.color unless event.color.blank?
json.allDay event.all_day_event? ? true : false
json.update_url event_path(event, method: :patch)
json.edit_url edit_event_path(event)
end


fullcalendar_js

var initialize_calendar;
initialize_calendar = function() {
$('.calendar').each(function(){
var calendar = $(this);
calendar.fullCalendar({
header: {
left: 'prev,next today',
center: 'title',
right: 'month,agendaWeek,agendaDay'
},
defaultView: 'agendaDay',
selectable: true,
selectHelper: true,
slotDuration: '00:60:00',
slotEventOverlap: false,
forceEventDuration: true,
minTime: '08:00:00',
maxTime: '20:00:00',
hiddenDays: [ 6, 7 ],
editable: true,
eventLimit: true,
events: '/events.json',

};
$(document).on('turbolinks:load', initialize_calendar);

Answer
eventRender: function(event, element) { 
              element.find('.fc-title').append("<br/>" + event.sala); 
          } ,
Comments