Remove that jquery-3.1.1.js and put app.js at the 1st order. As you already requiring jquery within bootstrap.js.
Feb 2, 2017
12
Level 6
Laravel 5.4 + VueJS + jQuery Full Calendar
Hi,
as soon as I installed laravel 5.4, I cant access jQuery plugins in Vue Components.
Calendar.vue
......
export default {
mounted() {
$('.fullcalendar-events').fullCalendar({
....
bootstrap.js (required in app.js)
....
window.$ = window.jQuery = require('jquery');
....
index.blade.php
....
<script type="text/javascript" src="https://code.jquery.com/jquery-3.1.1.js"></script>
<script type="text/javascript" src="assets/js/plugins/ui/moment/moment.min.js"></script>
<script type="text/javascript" src="assets/js/plugins/ui/fullcalendar/fullcalendar.min.js"></sc..
<script type="text/javascript" src="js/app.js"></script> (compiled app.js and components)
....
The error I get:
Uncaught TypeError: $(...).fullCalendar is not a function
If I dont use $().fullCalendar in VueJS and I put it just into my index.blade.php it works perfectly. Something I should know ?
Level 4
Hmm strange, i can load $fullcalendar without problem. Here my js file:
bootstrap.js
window.$ = window.jQuery = require('jquery');
/**
* Vue is a modern JavaScript library for building interactive web interfaces
* using reactive data binding and reusable components. Vue's API is clean
* and simple, leaving you to focus on building your next great project.
*/
window.moment = require('moment');
window.Pace = require('node-pace-progress');
/**
* We'll load the axios HTTP library which allows us to easily issue requests
* to our Laravel back-end. This library automatically handles sending the
* CSRF token as a header based on the value of the "XSRF" token cookie.
*/
window.axios = require('axios');
window.axios.defaults.headers.common = {
'X-CSRF-TOKEN': window.fyi.csrfToken,
'X-Requested-With': 'XMLHttpRequest'
};
/**
* Echo exposes an expressive API for subscribing to channels and listening
* for events that are broadcast by Laravel. Echo and event broadcasting
* allows your team to easily build robust real-time web applications.
*/
// import Echo from "laravel-echo"
// window.Echo = new Echo({
// broadcaster: 'pusher',
// key: 'your-pusher-key'
// });
page.js
const Vue = require('vue')
Vue.component('example', require('./../components/Example.vue'))
new Vue({
el: '#app'
});
Example.vue
<template>
<div class="col mt-5">
<div id="calendar"></div>
</div>
</template>
<script>
require('fullcalendar')
export default {
mounted() {
$('#calendar').fullCalendar()
}
}
</script>
Script load order, 1st is compiled app.js then page.js.
Here is the screenshot
1 like
Please or to participate in this conversation.