admin管理员组文章数量:1392059
I'm using in the project. I run into
problem when I need to get callback or trigger of next and prev buttons of calendar.
My api of backend built on parameter month returing events. I have request methods in Vuejs, which accept parameter and return events. For current month I just use the fetch method in created() function, it returns events and I simply make equals to calendar events, something like that:
axios.get(/fetch/events?month=6).then(e => this.events = this.responseToEvents(e.data)).catch( e => ...).
Now I need to understand when user click on next or previous buttons for triggering this request with property month and refetch events. I didn't find a way to make it, the only way is to use jQuery.
I'm using https://www.npmjs./package/vue-full-calendar in the project. I run into
problem when I need to get callback or trigger of next and prev buttons of calendar.
My api of backend built on parameter month returing events. I have request methods in Vuejs, which accept parameter and return events. For current month I just use the fetch method in created() function, it returns events and I simply make equals to calendar events, something like that:
axios.get(/fetch/events?month=6).then(e => this.events = this.responseToEvents(e.data)).catch( e => ...).
Now I need to understand when user click on next or previous buttons for triggering this request with property month and refetch events. I didn't find a way to make it, the only way is to use jQuery.
Share Improve this question asked Jun 16, 2018 at 11:04 DaveDave 5277 silver badges23 bronze badges 1- Your plugin is just a wrapper around fullcalender, which is a jQuery plugin. Every jQuery event is emitted through the plugin. You can just use on of these callbacks described in the doku fullcalendar.io/docs/event-display – reinerBa Commented Jun 16, 2018 at 19:19
3 Answers
Reset to default 4You can override default buttons:
<full-calendar ref="fullCalendar" :custom-buttons="customButtons" :header="header" />
<script>
data() {
return {
header: {
left: "prev,next today",
center: "title",
right: "dayGridMonth,timeGridWeek,timeGridDay,listWeek"
},
customButtons: {
prev: { // this overrides the prev button
text: "PREV",
click: () => {
console.log("eventPrev");
let calendarApi = this.$refs.fullCalendar.getApi();
calendarApi.prev();
}
},
next: { // this overrides the next button
text: "PREV",
click: () => {
console.log("eventNext");
let calendarApi = this.$refs.fullCalendar.getApi();
calendarApi.next();
}
}
}
}
</script>
Create a button yourself and give it a @click="next" event https://github./CroudTech/vue-fullcalendar#methods
Emitted Events: changeMonth
e.g.
<template>
<full-calendar
@changeMonth="changeMonth"
></full-calendar>
</template>
import FullCalendar from 'vue-fullcalendar'
...
ponents: {
FullCalendar
},
...
methods: {
changeMonth(start, end, currentMonthStartDate) {
console.log(currentMonthStartDate); // the start date of the current month after changing month by clicking the '<'(previous) or '>'(next) button
}
}
本文标签: javascriptVue Full Calendar (nextprev) buttons triggerStack Overflow
版权声明:本文标题:javascript - Vue Full Calendar (next, prev) buttons trigger - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744766044a2624045.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论