I have this bit of code refreshing the event when I update it.
event/update.js.erb
$('#calendar').fullCalendar('removeEvents', [<%= @event.id %>]);
$('#calendar').fullCalendar(
'renderEvent',
$.parseJSON("<%=j render(@event, format: :json).html_safe %>"),
true
);
Lot of my events are related and I would like to be able to call this manually on every event every time as one of them is updated.
I'm trying to do something like this but I've no idea how to make the javascript call and it doesn't feel right either.
def update
@event.update(event_params)
Event.all.each do |event|
# call event's javascript
end
end
Any suggestions on this ?