Giter Site home page Giter Site logo

vue-fullcalendar's Introduction

vue-fullcalendar

npm version Build Status

Installation

npm install --save vue-full-calendar

Or for Vue 1.x users

npm install --save [email protected]

Installing the plugin will globally add the full-calendar component to your project.

//main.js
import FullCalendar from 'vue-full-calendar'
Vue.use(FullCalendar)

But you can also import the standalone component to add locally or for more complex installations.

// foo.vue
import { FullCalendar } from 'vue-full-calendar'
export default {
  components: {
    FullCalendar,
  },
}

jQuery

Please note that fullcalendar depends on jQuery, but you won't need to add it to your project manually, fullcalendar will handle this for you automatically if jQuery is not detected.

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.

import 'fullcalendar/dist/fullcalendar.css'

Example App

I have created a simple Vue 2 webpack application as an example/playground https://github.com/BrockReece/vue-fullcalendar-example

or try out this Code Sandbox

Scheduler

For those wanting to use the scheduler plugin, this Code Sandbox shows you a full working 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>

Custom Config

You can pass any custom options through to fullcalendar by using the config prop, this includes extra event handlers.

<full-calendar :events="events" :config="config" />
...
<script>
...
  data() {
    return {
      events: [],
      config: {
        weekends: false,
        drop(...args) {
          //handle drop logic in parent
        },
      },
    }
  },
...
</script>

Locale

You can set the language of your calendar by importing the corresponding locale file and setting the locale key in the config prop. For example, to set up the Calendar in French...

<full-calendar :events="events" :config="config" />
...
<script>
import 'fullcalendar/dist/locale/fr'
...
  data() {
    return {
      events: [],
      config: {
        locale: 'fr',
      },
    }
  },
...
</script>

Code Sandbox

Note: You won't need to set the locale config key if your app only imports a single locale file

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

Methods

Sometimes you may need to manipulate the Calendar from your parent component, you can use fireMethod for this. This works with anything in the Fullcalendar docs suffixed with (method) and it will dynamically handle as many arguments as needed.

<full-calendar :events="events" ref="calendar" />
...
<script>
...
  data() {
    return {
      events: [],
    }
  },
  
  methods: {
    next() {
      this.$refs.calendar.fireMethod('next')
    },
    changeView(view) {
      this.$refs.calendar.fireMethod('changeView', view)
    },
  },
...
</script>

Events and Hooks

Emitted

  • event-selected(event, jsEvent, view) - Triggered on eventClick()
  • event-mouseover(event, jsEvent, view) - Triggered on eventMouseover()
  • event-mouseout(event, jsEvent, view) - Triggered on eventMouseout()
  • event-drop(event) - Triggered on eventDrop()
  • event-resize(event) - Triggered on eventResize()
  • event-created(event) - Triggered on select()
  • event-receive(event) - Triggered on eventReceive()
  • event-render(event) - Triggered on eventRender()
  • view-render(view, element) - Triggered on viewRender()
  • 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>

vue-fullcalendar's People

Contributors

askz avatar brockreece avatar casperlaitw avatar dominic-horbas avatar dschreij avatar ezracelli avatar fvmedia avatar luizguilhermefr avatar newnewcoder avatar noynek avatar petericebear avatar sadick254 avatar smingam avatar tibesyc avatar turnoverbnb avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vue-fullcalendar's Issues

how to add locale file in this vue2 component

There's a better way import (fullcalendar/dist/locale/zh-cn.js) file after used vue component( Vue.use(require('vue-full-calendar')) ) ? I don't want to add files(fullcalendar.css, fullcalendar.js, zh-cn.js)) in index.html page.

Load events after select dropdown is chosen

Currently assigning events to eventSources like so in methods;

changeSite(val) {
    console.log('changeSite '+JSON.stringify(val));

    this.events = this.eventSources;
},

this.eventSources goes to the data attribute like so;

data() {
    return {
        events: [],
        site: null,
        eventSources: [
            {
                events(start, end, timezone, callback) {
                    axios.get(`/api/events/${this.site}`).then(response => {
                        callback(response.data.data)
                    })
                }
            }
        ],
    }
}

But obviously ${this.site} can't be accessed there in the call.

Just wondering if you had a better way/idea as I'm stuck and not that great at JS/Vue :P

Error on the package

VM2482:1 Uncaught SyntaxError: Unexpected token import
import FullCalendar from './components/FullCalendar.vue';

toggle week in vu full calendar

Hello
I looking for a way to display or not the week in the calendar view

In my template I have
'''full-calendar :event-sources="eventSources" ref="calendar" id="calendar"full-calendar''''

this.$refs.fullCalendar('option',{weekends: false});

how to enable eventResize ?

hi Brock , me again....
sorry for this little stupid question :

i just cannot enable event resize (month view , week and day seems ok) , is there any condition i should write in the parent component?

in my parent component:

<full-calendar ref="calendar" :events="events" @event-selected="eventSelected" @day-click="dayClick" @event-resize="eventResize" @event-drop="eventDrop"></full-calendar>

and btw , if you can give me some advice to enable drop event from outside in vue way.

thanks a lot !!

Error in mounted hook

I'm getting this error when I first transisition to a page

Error in mounted hook: "TypeError: cal.fullCalendar is not a function"

Along with

cal.fullCalendar is not a function

But on page refresh it goes away and the calendar load and works as expected.

Thanks for any advice

Best way to customize events in eventRender

Hello everyone, I'm looking at the customization possibilites of events, and I'm wondering what would be a 'good' way.

As I found in issue #25 , I'm appending some html to the jquery element, but that's rather crude:

'eventRender' (event, element, view) {
    element.append(
        '<div class="event-details">' +
        '<div class="client">' + event.data.project.client + '<div>' +
        '<div class="user">' + event.data.task.user.name + ' @ ' + event.data.task.studio + '<div>' +
        '</div >'
    )
}

Is there a better way? Like, more vue-like (kinda, 'server-side' rendering of a component?), or something with templates at least?

Thanks a lot!
Steve

Events not firing

I think this a duplicate of #8 but, there isn't real and clear solution proposed so I think this need more attention.

I've been testing many solutions but the basic example should work I suppose.
You'll find my code below. Events are been loaded but I can't do anything with them... Kind of frustrating

<template>
  <div class="hello">
    <full-calendar :eventSources="eventSources"> </full-calendar>
  </div>
</template>

<script>
import Vue from 'vue'
import FullCalendar from 'vue-full-calendar'
window.jQuery = window.$ = require('jquery')

// import hub from '../main'
// import 
import axios from 'axios'
var fcEvents = null

export default {
  name: 'hello',
  data () {
    return {
        eventSources: [
        {
          events(start, end, timezone, callback) {
            axios.get('http://localhost:5000/rendezvous/events/')
            .then(function(response){
                console.log(response.data)
                fcEvents = response.data
                callback(response.data)
            })
          }
        }
      ]
    }
  },
  ready(){
    this.$on('event-resize', console.log('help'))
  },
  events: {
    'event-drop': function(event){
      console.log(event)
    }
  },
  methods: {
    'eventResize' (event) {
      console.log(event)
    },
    'eventClick' (event, jsEvent, pos) {
      console.log('eventClick', event, jsEvent, pos)
    },
  }
}

</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
h1, h2 {
  font-weight: normal;
}

ul {
  list-style-type: none;
  padding: 0;
}

li {
  display: inline-block;
  margin: 0 10px;
}

a {
  color: #42b983;
}
</style>
`

setting events array dynamically on mounted

Hey, I am trying to provide the events during the mounted lifecycle. However, I am unable to render the content on the calendar, no errors, no data, no nothing. Can somebody help me with this? Currently I have:

mounted(){
        let self = this
        var tipo = this.$route.params.tipo
        if (tipo==='usuario'){
            var userslug = this.$route.params.slug
            api.request('GET','calendario?unidade=1&dtinicio=2017-06-01&dtfim=2017-07-10').then(function(response){
                self.events= [
                    {
                        title  : 'event1',
                        start  : '2017-06-24',
                    },
                    {
                        title  : 'event2',
                        start  : '2017-06-23',
                        end    : '2017-06-24',
                    },
                    {
                        title  : 'event3',
                        start  : '2017-06-24T12:30:00',
                        allDay : false,
                    },
                ]
                console.log(self.events)
                self.$refs.calendar.$emit('rerender-events')
            }).catch(function(error){
            })
        }
  },

and

<full-calendar ref="calendar" :events="events" :config="config"  @event-selected="eventSelected"></full-calendar>

and

  data() {
    return {
     events: [],
      
      config: {
        locale: 'pt-br',
        editable: false,
        aspectRatio: 1.35,
        views: {
            week: {
                columnFormat: 'ddd D/M'
            }
        },
        buttonText: {
            today:    'hoje',
            month:    'mรชs',
            week:     'semana',
            day:      'dia',
            list:     'lista'
        },

      }
    }
  },

the events array prints fine. Once I get this working I'll manage to use the response provided by my API.
regards,
Joรฃo

No jQuery

Hey,
Just tested out your component and I don't have jQuery installed in my project, so when I load the component I get:

FullCalendar.vue?d3c2:64 Uncaught (in promise) ReferenceError: $ is not defined(โ€ฆ)

Just thought you should know,
Andrew

Support vue2

This library doesn't seem to be compatible with Vue 2.x ๐Ÿ˜ข

import to my vue component not rendering

when i am trying to import this component to my project --a laravel-backend -- , to a single file component , it does not render.

i know , it is 100% my problem , and i really need some advice. thanks !

btw , i download the sample you gave , it works , but i just cannot use it in my project.

How to get event's drop position?

According to official full calendar docs (https://fullcalendar.io/docs/event_ui/eventDrop/) drop event should hold delta duration object which shows where is dragged event actually dropped.

In current implementation ("event-drop" event) we only have access to event object once drop is triggered, is there any way to determine event's drop position using current vue-fullcalendar version?

create Jalali calendar

Hi
I want vue-fullcalendar ad date Chang to vue-fullcalendar Jalali(persian)
(Gregorian to Jalali calendar)
how can i do that
some like this

image

ho can i do that please guide me ,
Tanx for help ....

eventDrop not always keeping moved items when switching months (no refresh)

Sometimes the events that have been moved, reset after changing months and then going back.

Is there anything special I need to do to make sure they update and not reset?

eventDrop: (event, delta, revertFunc) => {
    console.log(event.title + " was dropped on " + event.start.format());

    self.$refs.calendar.$emit('event-drop', event, delta, revertFunc);
},

eventResized Assigning Event Object

First off, huge thank you for building and maintaining this and being so responsive. Here's an issue I can't figure out.

When a user resizes an event, I want to show a modal where they can edit some of the event info and confirm their change.

I'm using the following to set a selectedEvent property. It appears to work, but if you resize a second or third time, you can see that the dragging behavior breaks.

eventResized: function(event) {
    //this is where the problem happens'
    this.selectedEvent = event;
}

I did an additional test of assigning to an outside variable and it doesn't cause the same problem.

var selectedEvent;

eventResized: function(event) {
    //no problem here, but the event data is no longer in the Vue scope.
    selectedEvent = event;
}

Here's a codepen showing the behavior. Any suggestions?
https://codepen.io/noynek/pen/OjjWeY

ajax request on full calendar

Hello ,
I try to make ajax request with vu full calendar but it did nt work

<script> export default { name: 'home', computed: { eventSources(start, end, timezone,callback) { const self = this; return $.ajax({ url: '/toto' type: "GET", dataType: "json", success: function (data) { callback(data); }, error: function () { } }); }, }, } </script> <style>

Problem with Router

Hello Guys! I have a problem when i redirect to another page and back to page with calendar.. all events stop working..
Im using vue-router
It seems that the emit does not arrive until the event

<router-link :to="{ name: 'home' }">Home</router-link>
<router-link :to="{ name: 'calendar' }">Calendar</router-link>

Dont make us require to use built in css

In the component you require us to use their CSS

<style src="../../fullcalendar/dist/fullcalendar.css"></style>

Id rather allow the developer to include this themselves. As there are times when they do not want to inject the css directly into dom

Vuex + eventSources

Hello guys, i want add Vuex + eventSources in my app.. its possible?
I try but i have no success.. thanks!

Support for external draggable events?

Thanks for a great wrapper!

Issue:
Doesn't work with external draggable events through jQuery UI, is this something that is on the roadplan? The eventDrop listener is only for event that are dragged from inside the cal, not triggering on external drop, the drop() method must be implemented in that case i believe? OR have i totally missed something? :D

background rendering dates

Hi there,

I have a display issue using background rendering.
The colour is overlapping on some dates and also starting at +- 30% of the cell
A mouse click on a specific date is also selecting two contiguous cells

Thank you for your help

 config: {
          header: {
            left: '',
            center: 'title',
            right: 'prev,next today'
          },
          height: 550,
          timeFormat: 'HH:mm',
          firstDay: 1,
          navLinks: false,
          editable: false,
          defaultView: 'month',
          overlap: false,
          viewRender: this.calViewRender
        },

"loop ..."
vLeave.push({
   start: datePush,
   color: 'red', 
   rendering: 'background',
   allDay: true
  })

Please require jquery in your component

Please put

var $ = require('jquery')

in your FullCalendar.vue.

I don't need jquery but have another lib which defines $

And I think if your component depends on jquery, it should require it by it self.

Extend API coverage of fullcalendar events

If you check fullcalendar's documentation for the functions eventDrop and eventResize, you can see that they pass multiple arguments to the event handling function. From all these parameters, the vue component currently only passes on the event object.

I think it would be an improvement to pass on all parameters to the vue event handler. In particular, the removeFunc parameter is very useful for reverting changes to the calendar (e.g. put an event back at its old place after a drag, or resize back to its original size) if the user wasn't allowed to make the change, or an ajax request that is made in the event callback fails. This change should be possible without breaking backward compatibility as the newly passed arguments are simply discared if they are not caught/assigned in the event callback function.

I am willing to work on this and send you a PR, if you are open to this.

selectable bug

when i create some event this event not The calendar remains when i clicked this, this event is remove how fix this problem...

lodash noconflict?

Is it possible that when lodash is imported that is set into no conflict mode?

I have other packages being included that are using underscore and it causing a bit of an issue for me as they keep treading on each other.

Or if someone can tell me if there is a way i can set it to no conflict etc without too much hassle.

Thanks.

minify version of vue-fullcalendar

I want to have a minify version of vu-fullcalendar so that I can include it on index.html like this:

<script src="s/vu-fullcalendar.js"></script>

Thanks

Events not updating

Inside of my calendar.vue component I have a fullcalendar component.
Within calendar.vue I have a method called submit. Inside of submit I make a
(successful) reference to the fullcalendar component with
"this.$refs.calendar". However when I do
"this.$refs.calendar.$emit('refetchEvents');" in my submit function the
events are not fetched (my events are not updated on my calendar). Why
are my events not being updated upon submit and how can I update them?

The (relevant) code for the calendar.vue component can be found here:
https://github.com/randymoss94/calendar.vue/blob/master/eventQuestion.vue

and the full project can be found here:
https://github.com/randymoss94/schedulerCurrent

ChangeView

How can i change the view of full calendar? My default view is 'month', but i want to change to 'listYear' when i search for something on the calendar

Example project stop working after updating packages deps

Steps to reproduce ::
clone example project, populate modules, everything works
update dependency tree with ncu -u, install upgrades, then Vue complains about "template or render function not defined"

upgrade tree ::
autoprefixer ^6.7.2 โ†’ ^7.1.4
babel-loader ^6.2.10 โ†’ ^7.1.2
chalk ^1.1.3 โ†’ ^2.1.0
css-loader ^0.26.1 โ†’ ^0.28.7
eslint ^3.14.1 โ†’ ^4.6.1
eslint-config-airbnb-base ^11.0.1 โ†’ ^12.0.0
eslint-friendly-formatter ^2.0.7 โ†’ ^3.0.0
eslint-plugin-html ^2.0.0 โ†’ ^3.2.1
extract-text-webpack-plugin ^2.0.0 โ†’ ^3.0.0
file-loader ^0.10.0 โ†’ ^0.11.2
opn ^4.0.2 โ†’ ^5.1.0
optimize-css-assets-webpack-plugin ^1.3.0 โ†’ ^3.1.1
vue-loader ^11.1.4 โ†’ ^13.0.4
vue-style-loader ^2.0.0 โ†’ ^3.0.1
webpack ^2.2.1 โ†’ ^3.5.6
webpack-merge ^2.6.1 โ†’ ^4.1.0

Edit : after some trys, found that downgrading vue-loader solve the issue

changhe locale ('fa')

Hi dear
i want Chang locale and calendar to Persian in vue-fullcalendar...
so i don't now how do that in vue please Guide me...
Tnx....

Scheduler resources issue

Hello, I've added fullcalendar-scheduler to my project, and it works mostly fine. Still, there are some stuff missing in todays FullCalendar.vue file, i.e. support for resources. Is there any extra content available for the scheduler additions, or will I have to write it all myself? My problem atm is setting up a render for resources.

Failed to mount component: template or render function not defined

Hi,
I suspect this is a config issue- but I've followed the style of the example project. Despite that, still get this error.

My set up code is like this (in main.js):

Vue.use(require('vue-full-calendar'))

The usage, (in another component) is like this:

HTML Section:

<vue-full-calendar :events="selEvents" @eventClick="eventSelected">
</vue-full-calendar>

Script Section:

...
import VueFullCalendar from 'vue-full-calendar'

export default {
  components: {
    GeneralAction,
    VueFullCalendar
  },
...

BTW I've included the CSS import in App.vue - the main entry point.

Any pointers as to what I'm doing wrong would be great! :-)

Error: [vuex] Do not mutate vuex store state outside mutation handlers.

Hello, I'm quite new to the wonderfull world of Vue and trying to use this very useful wrapper with a vuex store... I'm kind of tearing my hairs appart with this problem!
Here's what i'm doing, nothing fancy I think:

<full-calendar ref="calendar" :events="eventsFromStore" @event-resize="eventResize" @event-created="eventCreated" @event-drop="eventMoved"></full-calendar>

...
    computed: {
        ...mapGetters({    
            eventsFromStore: 'allEvents'
        })
    }
...
    methods: {
        'eventResize' (event) {
            this.$store.dispatch('updateEvent', event)
        },
        'eventCreated' (event) {
            this.$store.dispatch('createEvent', event)
        },
        'eventMoved' (event) {
            this.$store.dispatch('updateEvent', event)
        }
    },
    created () {
        this.$store.dispatch('getAllEvents')
    }

It appears that the events array is passed to fullcalendar which is directly modifying it, which is not allowed in strict mode. I tried to mitigate that by having a cloned array passed to events, to no avail (the vue store functions are cloned too?). There is also a problem of infinite loop in the events watcher, so I'm wondering if it's me or if there is something else.
From what I understand, removing events modify this.events so vue trigger the watcher again.

watch: {
            events: {
                deep: true,
                handler(val) {
                    $(this.$el).fullCalendar('removeEvents')    // this is triggering this same watcher on events!
                    $(this.$el).fullCalendar('addEventSource', this.events)
                },
            }
}

From what I've gather, cloning the array coming from the props is a good practice, but since I'm new to vue, I'm wondering what are the side effects...
Here is what i'm doing, any thoughts? :

    created () {
        this.clonedEvents = _.cloneDeep(this.events)
    },

    data () {
        return {
            clonedEvents: []
        }
    },

    watch: {
        events: {
            deep: true,
            handler (val, old) {
// if( _.difference(val, old).length > 0)   // wouldn't hurt (but perf?) to check if there is really a difference before updating
                this.clonedEvents = _.cloneDeep(this.events)
                $(this.$el).fullCalendar('removeEvents')
                $(this.$el).fullCalendar('addEventSource', this.clonedEvents)
            },
        }
    }

Thanks for your help!

Add listener for eventRender events

I have bumped into several occasions now in which it would be useful to be able to listen for fullCalendar's eventRender events. This event is fired when a new event is rendered on the calendar and allows to change markup or attach other functionality to the DOM element that represents the event in the calendar. This is for instance useful for initialising and attaching a [bs popover] or [qtip] to the event's DOM element when it is created. The visibility of the attached popovers can then be toggled using the existing eventSelected event. Here is an example of this with a bootstrap popover and with an imaginary event-rendered callback:

<template>
    <full-calendar 
	ref="calendar" 
	@event-selected="eventSelected"
	@event-rendered="eventRendered"
    ></full-calendar>
</template>

<script>
new Vue({
    ...
    methods: {
        eventRendered(event, element, view){
            $(element).popover({
		html: true,
		container: '.fc-scroller',
		placement: 'auto right',
		title: event.title,
		content: 'Start: ' + event.start + '<br />End: ' + event.end
	    });
        },
        eventSelected(event, jsEvent){
            $(jsEvent.target).popover('toggle');
        }
    }
    ...   
})
</script>

I currently solve this by manually linking fullCalendar's eventRender() callback to a vue-method in my component's mounted section, but I think it is more elegant to integrate this in the full-calendar component itself.

What do you think? Would you like me to send a pull request with this feature?

Event listener not working

I've tried to call the event refetch-events but it is not working.
The event is not being fired.

I have to call it inside of the component and outside of it. I've tried to log some info to see if the event is being fired, but it's not.

I've used

$(this.$el).fullCalendar('refetchEvents');
and
$(self.$el).trigger('refetchEvents');
and
$(self.$el).trigger('refetch-events', event);

but it doesn't works.
I call an iframe to create the event and after it closes, the event is created and I need to refetch them.

Here's a piece of my code:

    select(start, end, jsEvent) {
        var data = start.format("YYYY-MM-DD");
        var dia = start.format("dddd");

        $.fancybox({
            type: "iframe",
            href: "http://127.0.0.1:8000/admin/agendamentos/create",
            width: "80%",
            height: "90%",
            afterLoad: function() {
                    $(".fancybox-iframe").contents().find("input[name='dia_semana']").val(dia);
                    $(".fancybox-iframe").contents().find("select[name='profissionais[]']").attr("disabled","disabled");
                    $(".fancybox-iframe").contents().find("input[name='data']").val(data);
                    $(".fancybox-iframe").contents().find("input[name='data']").attr("readonly","readonly");
            },
            afterClose: function(){
                    console.log('afterclose');
                    $(self.$el).trigger('refetch-events');
             }
        });
    },

I'll need to call this event not only inside the component, but also outside of it. Once an event is created inside my Fancybox iframe, I'll send a notification to other users and also update their views, by refetching the events. I am already sending a live notification, but I need also the event to appear on the calendar without having to refresh the page. How can I get it working?

Here's the full code:

<template>
    <div ref:"calendar" id="calendar" :event-sources="eventSources">
    </div>
</template>

<script>
    require('fullcalendar')

    export default {
        props: {
            events: {
                default() {
                    return []
                }
            },
            eventSources: {
                default() {
                    return [
                        {
                            events(start, end, timezone, callback) {
                                Vue.http.get('http://127.0.0.1:8000/getAgendamentosEventos', {timezone: timezone}).then(response => {
                                    callback(response.data.events)
                                })
                            },
                            color: '#1ABC9C',
                        },
                        {
                            events(start, end, timezone, callback) {
                                Vue.http.get('http://127.0.0.1:8000/getDatasFechadas', {timezone: timezone}).then(response => {
                                    callback(response.data.events)
                                })
                            },
                            color: '#DC0000',
                        }
                    ]
                },
            },
            editable: {
                default() {
                    return true
                },
            },
            selectable: {
                default() {
                    return true
                },
            },
            selectHelper: {
                default() {
                    return true
                },
            },
            header: {
                default() {
                    return {
                        left:   'prev,next today',
                        center: 'title',
                        right:  'month,agendaWeek,agendaDay'
                    }
                },
            },
            defaultView: {
                default() {
                    return 'month'
                },
            },
            sync: {
                default() {
                    return false
                }
            },
        },
        mounted() {
            const cal = $(this.$el),
                self = this;

            cal.fullCalendar({
                header: this.header,
                defaultView: this.defaultView,
                editable: this.editable,
                selectable: this.selectable,
                selectHelper: this.selectHelper,
                aspectRatio: 2,
                slotDuration: '00:10:00',
                timeFormat: 'HH:mm',
                events: self.events,
                eventSources: self.eventSources,
                fixedWeekCount: false,
                eventRender(event, element) {
                    if (this.sync) {
                        self.events = cal.fullCalendar('clientEvents')
                    }
                },
                eventDestroy(event) {
                    if (this.sync) {
                        self.events = cal.fullCalendar('clientEvents')
                    }
                },
                eventClick(event) {
                    $(self.$el).trigger('event-selected', event);
                    console.log('click');
                    console.log(event);
                },
                eventDrop(event) {
                    console.log('drop-event');
                    $(self.$el).trigger('event-drop', event);
                },
                eventResize(event) {
                    $(self.$el).trigger('event-resize', event)
                },
                select(start, end, jsEvent) {
                    var data = start.format("YYYY-MM-DD");
                    var dia = start.format("dddd");

                    console.log(event);

                    $.fancybox({
                            type: "iframe",
                            href: "http://127.0.0.1:8000/admin/agendamentos/create",
                            width: "80%",
                            height: "90%",
                            afterLoad: function() {
                                $(".fancybox-iframe").contents().find("input[name='dia_semana']").val(dia);
                                $(".fancybox-iframe").contents().find("select[name='profissionais[]']").attr("disabled","disabled");
                                $(".fancybox-iframe").contents().find("input[name='data']").val(data);
                                $(".fancybox-iframe").contents().find("input[name='data']").attr("readonly","readonly");
                            },
                            afterClose: function(){
                                console.log('afterclose');
                                $(self.$el).trigger('refetch-events');
                            }
                    });
                },
            });
        },
        watch: {
            events: {
                deep: true,
                handler(val) {
                    const cal = $(this.$el)
                    cal.fullCalendar('removeEvents')
                    cal.fullCalendar('addEventSource', this.events)
                    cal.fullCalendar('rerenderEvents')
                    cal.fullCalendar('refetch-events')
                    cal.fullCalendar('refetchEvents')
                },
            }
        },
        events: {
            'remove-event'(event) {
                $(this.$el).fullCalendar('removeEvents', event.id)
            },
            'rerender-events'(event) {
                $(this.$el).fullCalendar('rerenderEvents')
            },
            'refetch-events'(event) {
                console.log('refetch');
                $(this.$el).fullCalendar('refetchEvents');
            },
            'render-event'(event) {
                $(this.$el).fullCalendar('renderEvent', event)
            },
            'reload-events'() {
                $(this.$el).fullCalendar('removeEvents')
                $(this.$el).fullCalendar('addEventSource', this.events)
            },
            'rebuild-sources'() {
                $(this.$el).fullCalendar('removeEvents')
                this.eventSources.map(event => {
                    $(this.$el).fullCalendar('addEventSource', event)
                })
            },
        },
    }
</script>

Multiple Event Sources Only Using First

I've got two eventSources: a JSON feed and a function that returns events. The problem is that only the first eventSource is getting called. Am I missing something?

    data: function () {
        var self = this;
        return {
            eventSources: [{
                events: function (start, end, timezone, callback) {
                    var events = getEvents(start, end, timezone);
                    callback(events)
                },
                events: function (start, end, timezone, callback) {
                    self.$http.get('//myjsonfeed', {
                        params: {
                            start: start.format(),
                            end: end.format()
                        }
                    }).then(function (response) {
                        callback(response.data);
                    });
                }
            }],`

I am having issues refreshing events when I add a new one

Here is some code to better illustrate what I am doing (err, trying to do):

<template>
<div>
    <full-calendar ref="calendar" :event-sources="eventSources"  @day-click="daySelected" @event-selected="eventSelected" :config="config"></full-calendar>

    <!-- Modal Component -->
    <b-modal ref="my_modal" title="New Appointment" @ok="submit" @shown="clearModalValues">
      <form @submit.stop.prevent="submit">
        <label>Client:</label>
        <b-form-select v-model="selectedClient" :options="clientOptions" class='mb-3'></b-form-select>

        <label>Service:</label>
        <b-form-select multiple v-model="selectedService" :options="serviceOptions" class='mb-3'></b-form-select>

        <label>Start time:</label>
        <time-picker v-model="myTime"></time-picker>

        <label>Notes:</label>
        <b-form-input textarea v-model="notes" placeholder="Notes"></b-form-input>
      </form>
    </b-modal>
    <!-- /Modal Component -->

  </div>
</template>

<script>
export default {
  props: {
    staff:{
      type: Number,
      required: true
    },
  },
  data() {
    return {
      myTime: new Date(),
      selectedService: [null],
      selectedClient: null,
      selectedStartTime: new Date(),
      notes: null,
      serviceOptions: [],
      clientOptions: [],
      events: [],
      config: {
        timeFormat: 'h(:mm)',
        eventClick: (event) => {
          console.log('Event Clicked: '+event.title);
        },
      },
      selected: {},
    };
  },
  computed: {
    eventSources() {
      return [
        {
          events(start, end, timezone, callback) {
            axios.get('/getEvents').then(response => {
              callback(response.data)
            })
          }
        }
      ]
    }
  },
  mounted() {
    this.myTime = new Date()
    axios.get('/getClients').then(response => this.clientOptions = response.data);
    axios.get('/getServices').then(response => this.serviceOptions = response.data);
  },
  methods: {
    clearModalValues() {
      this.selectedService = [null];
      this.selectedClient = null;
      this.selectedStartTime = new Date();
      this.myTime = new Date();
      this.notes = null;
    },
    submit(e) {
 
      axios.post('/addEvent/',{'selectedService':this.selectedService,'selectedClient':this.selectedClient,'selectedStartTime':this.selectedStartTime,'notes':this.notes}).then(function(response){
        //console.log(response.data);
        new PNotify({
          title: 'Success',
          text: 'New event has been created',
          icon: 'icon-checkmark3',
          type: 'success'
        });

        this.selectedService = [null];
        this.selectedClient = null;
        this.selectedStartTime = new Date();
        this.notes = null;
        this.myTime = new Date();

       // ******** I HAVE TRIED THESE CALLS AS PER DOCUMENTATION **********
       //this.$refs.calendar.fireMethod('refetch-events')
        //this.$refs.calendar.fullCalendar.$emit('refetch-events');
        //this.$refs.calendar.$emit('refetch-events');

        console.log(this.$refs.calendar);
      }.bind(this));
    },
    eventSelected(event) {
      console.log('Event Selected: '+event.title);
    },
    daySelected(date,event,view){
      this.$refs.my_modal.show();
      this.selectedStartTime = date.format("YYYY-MM-DD HH:mm:ss");
      this.myTime = date.toDate();
    },
  },
};
</script>

I keep getting errors when I try and call refresh-events. Events are there on load but when I add a new one I cannot get the data to refresh or to call eventSources to refetch the events. Any help would be greatly appreciate!

Events not displayed dynamically

Using <full-calendar ref="calendar" :events="events" ... it works if events is hardcoded in data like below

But if I try to display data from a database, e.g. using VUEX with the mounted() vue method
nothing appears

<template>
<full-calendar ref="calendar" :events="list" ...>
{{ list }}
</template>

<script>
 data() {
      return {
        events: [
	{
	   title: 'All Day Event',
            start: '2017-06-01'
	}],
        newlist: [ 
	{
	    title: 'new data',
            start: '2017-06-02'
	}],
 
methods: {
      ...mapActions([
        'retrieveAllEvents'
      ]),
computed: {
      ...mapGetters({
        list: "getAllEvents"
      })
 },
mounted() {
      this.retrieveAllEvents()
}

If I'm hardcoding returned result in data: events, it's displayed properly
{{ list }} is displayed properly

Same problem if I try to change dynamically the events source (both based in data) using

this.$refs.calendar.$emit( 'renderEvent', this.newlist, true);

Any Help Will Be Welcome

Events listener not firing

events: {
    'event-selected'(event) {
      console.log(event);
    }
  },

This is in my component that wraps <full-calendar> (Vue 1.0 version, 0.0.3), yet it never gets fired. The event-selected event is being dispatched as I can see using Vue devtools, which is why this isn't making any sense.

Am I dumb or is something wrong?

Edit: editable and selectable props don't seem to work either. I have to map my events to add the editable variable.

Error: Couldn't find preset "latest" relative to directory

Hello,

I'm totally new to both Vue and FullCalendar, and having an issue I can't really understand. Maybe it's super-simple, maybe not. Here's the full error-message:

ERROR in ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib/selector.js?type=script&index=0&bustCache!./node_modules/vue-full-calendar/components/FullCalendar.vue Module build failed: Error: Couldn't find preset "latest" relative to directory "/Users/magnus/Documents/dev/todo-app/node_modules/vue-full-calendar" at /Users/magnus/Documents/dev/todo-app/node_modules/babel-core/lib/transformation/file/options/option-manager.js:293:19 at Array.map (native) at OptionManager.resolvePresets (/Users/magnus/Documents/dev/todo-app/node_modules/babel-core/lib/transformation/file/options/option-manager.js:275:20) at OptionManager.mergePresets (/Users/magnus/Documents/dev/todo-app/node_modules/babel-core/lib/transformation/file/options/option-manager.js:264:10) at OptionManager.mergeOptions (/Users/magnus/Documents/dev/todo-app/node_modules/babel-core/lib/transformation/file/options/option-manager.js:249:14) at OptionManager.init (/Users/magnus/Documents/dev/todo-app/node_modules/babel-core/lib/transformation/file/options/option-manager.js:368:12) at File.initOptions (/Users/magnus/Documents/dev/todo-app/node_modules/babel-core/lib/transformation/file/index.js:212:65) at new File (/Users/magnus/Documents/dev/todo-app/node_modules/babel-core/lib/transformation/file/index.js:135:24) at Pipeline.transform (/Users/magnus/Documents/dev/todo-app/node_modules/babel-core/lib/transformation/pipeline.js:46:16) at transpile (/Users/magnus/Documents/dev/todo-app/node_modules/babel-loader/lib/index.js:50:20) at Object.module.exports (/Users/magnus/Documents/dev/todo-app/node_modules/babel-loader/lib/index.js:175:20) @ ./node_modules/vue-full-calendar/components/FullCalendar.vue 4:0-122 @ ./node_modules/vue-full-calendar/index.js @ ./src/main.js @ multi ./build/dev-client ./src/main.js

Reactive events

Are the events supposed to be reactive? I am able to render the initial events:

full-calendar(ref='full-calendar',:events="filteredEvents")

However, any update to the events are not shown on the calendar. I also tried to trigger the 'rerender-events' event on the full-calendar but did not see the updated events rendered:

window.jQuery(this.$refs['full-calendar']).trigger('rerender-events')

Has anyone been able to update events and see the changes on the calendar? FYI, my filteredEvents are computed properties and I am able to see the updates with pre {{filteredEvents}}. I've also tried to render the vuex store object itself and make changes to that object to no avail.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.