Comments (5)
By the way, I see you provide the option to alter the method callbacks by overwriting them in the config
object that can be passed to the component, so this issue is not a critical one. Still, wouldn't it be better to pass on all arguments of fullcalendar's events to vue event handlers?
from vue-fullcalendar.
Well, that is harder than it seemed, as it is really difficult to get the context of the function right. It is very hard to let self and this point to the vue-calendar component, and thus to call the $emit function to fire the appropriate events.
I had to put this in the config object that is passed from the parent component into vue-fullecalendar to get this to work:
config:{
eventDrop: (event, delta, removeFunc) => {
this.$refs.calendar.$emit('event-drop', event, delta, removeFunc);
},
eventResize: (event, delta, removeFunc) => {
this.$refs.calendar.$emit('event-resize', event, delta, removeFunc);
},
}
where $refs.calendar points to the vue-calendar component
from vue-fullcalendar.
Hi @dschreij
Yeah I am always open to PR's and I agree that it would be useful.
As for your third message, shorthand functions do something magic with the scope behind the scenes, it might be easier to pass through a traditional function with a bind method pointing towards this.$refs.calendar
but I guess I don't really see why you would want to scope the calendar component anyway?
Cheers
Brock
from vue-fullcalendar.
Hi Brock,
The reason for my current solution using shorthands is that I haven't been able to get access to the vue component and its methods (such as $emit) when passing these functions in the config object. I do need to scope the calendar component to get access to its $emit function, am I right?
I did play around with bind() but wasn't able to set the this reference to the full-calendar component.
I tried:
config:{
eventDrop: (function(event, delta, removeFunc) {
this.$emit('event-drop', event, delta, removeFunc);
}).bind(this.$refs.calendar),
eventResize: function (event, delta, removeFunc) {
this.$emit('event-resize', event, delta, removeFunc);
}).bind(this.$refs.calendar),
}
but this results in this
being undefined
. This is probably due to generating the config object in the data()
function instead of created()
or mounted()
and as such, the components haven't been properly mounted and referenced yet.
I also played around referencing this
in a self
var (like you did), but to no avail.
I think the cleanest way of realising this, is to pass all these arguments through the default built-in functions, so I'll send you a PR shortly.
from vue-fullcalendar.
Yeah, I think you are right that my suggestion would have only worked on a properly mounted component.
Thanks, I appreciate your help.
Brock
from vue-fullcalendar.
Related Issues (20)
- Full Calendar Month View Issue HOT 1
- Problem with a select and v-if in the fullcalendar component
- event.end is null when drap fullDay event drop to agenda. HOT 3
- Time Format
- eventResources doesn't work on calender scheduler
- Title Undefined HOT 11
- Change in class binding breaks rendering HOT 4
- add theme bootstrap
- IE11, npm run dev vue proect Error HOT 2
- An example of using vue-calendar using Rrule
- how to use event-limit
- fullCalendar is not working HOT 7
- Cannot read property 'footprint' of undefined HOT 13
- Component not registering. HOT 2
- Error in callback for watcher "events": "TypeError: jquery__WEBPACK_IMPORTED_MODULE_2___default(...)(...).fullCalendar is not a function #21 HOT 4
- Error in mounted hook: "TypeError: cal.fullCalendar is not a function" HOT 16
- Invalid after ‘daynames’ property is set HOT 2
- Difference in package dependencies HOT 1
- Event not responding the correct way, it stacks on the second day HOT 1
- Can i click on time labels. HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vue-fullcalendar.