vue-fullcalendar
Installation
npm install --save vue-full-calendar
Or for Vue 1.x users
npm install --save vue-full-calendar@0.0.3
and use in your project
Vue.use(require('vue-full-calendar'))
jQuery
Please note that fullcalendar depends on jQuery, so it will need to be included in your project for this vue plugin to work
window.jQuery = window.$ = require('jquery')
CSS
As of version 2.0, we have removed the automatic import of the fullcalendar.css, you will need to explicitly import this css file in your project.
<style>
@import '~fullcalendar/dist/fullcalendar.css';
</style>
Example App
I have created a simple Vue 2 webpack application to as an example/playground https://github.com/BrockReece/vue-fullcalendar-example
Basic Usage
You can pass an array of fullclendar objects through the props
<full-calendar :events="events"></full-calendar>
...
<script>
...
data() {
return {
events: [
{
title : 'event1',
start : '2010-01-01',
},
{
title : 'event2',
start : '2010-01-05',
end : '2010-01-07',
},
{
title : 'event3',
start : '2010-01-09T12:30:00',
allDay : false,
},
]
}
}
...
</script>
More event options can be found at http://fullcalendar.io/docs/event_data/Event_Object/
Using a JSON Feed
<full-calendar :event-sources="eventSources"></full-calendar>
...
<script>
...
data() {
return {
eventSources: [
{
events(start, end, timezone, callback) {
self.$http.get(`/myFeed`, {timezone: timezone}).then(response => {
callback(response.data.data)
})
},
color: 'yellow',
textColor: 'black',
},
{
events(start, end, timezone, callback) {
self.$http.get(`/anotherFeed`, {timezone: self.timezone}).then(response => {
callback(response.data.data)
})
},
color: 'red',
},
]
}
}
...
</script>
Further Props
You can edit the look and feel of fullcalendar by passing through extra props. These all have sensible defaults
- header - [obj] - docs
- defaultView - ['agendaWeek'] - docs
- editable - [true] - docs
- selectable - [true] - docs
- selectHelper - [true] - docs
- config - [true] - Pass your own custom config straight through to fullcalendar
Events and Hooks
Emitted
- event-selected(event, jsEvent, view) - Triggered on eventClick()
- event-drop(event) - Triggered on eventDrop()
- event-resize(event) - Triggered on eventResize()
- event-created(event) - Triggered on select()
- day-click(date, jsEvent, view) - Triggered on dayClick()
You can listen for these events using the following markup
<full-calendar :event-sources="eventSources" @event-selected="eventSelected"></full-calendar>
Listens on
- render-event(event) - Adds a new event to calendar
- remove-event(event) - Removes event from calendar
- rerender-events() - Rerenders events to reflect local changes
- refetch-events() - Makes another JSON call to event sources
- reload-events() - Removes all events and adds all events in this.events
You can trigger these events in the parent component like so...
<full-calendar ref="calendar" :event-sources="eventSources"></full-calendar>
...
<script>
...
methods: {
refreshEvents() {
this.$refs.calendar.$emit('refetch-events')
},
}
...
</script>