Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

uloncl's avatar

jQuery.Deferred exception: Quill is not defined

i keep getting the error in the title i have import ''quill/quill"; and const Quill = require("quill"); in app.js i have ran npm run build i have @vite(['resources/sass/app.scss', 'resources/js/app.js']) in the view and the script is just var quill = new Quill('#editor', { theme: 'snow', }); which is in a component.

0 likes
14 replies
Sinnbeck's avatar

Is the script in the view? Like an inline script? If so you need to bind quill to the window

In the app.js

window.Quill = Quill;
uloncl's avatar

@Sinnbeck i added window.Quill = Quill; to app.js and ran npm run dev and it didnt work, yes its an inline script in standard <script></script> tags

uloncl's avatar

@Sinnbeck basically i have a button to take the input from the first quill and create a new disabled quill with the input from the first quill (after sending the contents of the first quill to a controller to add the commetn to the database)

<script>
        $(document).ready(function() {

            var newComment = new Quill('#new_comment', {
                placeholder: 'Write a comment...',
                theme: 'snow',
                modules: {
                    toolbar: [
                        ['bold', 'italic', 'underline'],
                        ['blockquote', 'code-block'],
                        ['link'],
                        [{
                            'list': 'ordered'
                        }, {
                            'list': 'bullet'
                        }],
                        [{
                            'indent': '-1'
                        }, {
                            'indent': '+1'
                        }],
                        ['clean']
                    ]
                }
            });

            $('.ql-toolbar').addClass('rounded-top');

            $('.ql-tooltip').css('max-height', '0');//yes i know this is a bad idea

            $('#add-comment').click(function() {
                if ($('#booking-log').length) {
                    var comments = [];
                    var repairs = [];
                    $('#booking-log > div').each((index, elem) => {
                        if (elem.id.split('-')[1] == 'comment') {
                            postedComment.setContents("newComment.getContents()");
                        }
                    })
                } else {
                    $('#right-section').append('<div><div class="card mb-3" style="width: 50rem;"><h5 class="card-header">Booking Log</h5><div class="card-body d-flex flex-column" id="booking-log"></div></div></div>');
                    $.ajax({
                        url: '/comment/add',
                        type: 'POST',
                        dataType: 'json',
                        data: {
                            booking_id: {{ $booking->booking_id }},
                            delta: newComment.getContents()
                        },
                        success: function(data) {
                            console.log(data);
                            $('#booking-log').prepend('<div class="card"><div id="posted-comment-1" class="ql-container ql-bubble h-0" style="min-height: 2rem"></div></div>');
                            var postedComment = new Quill('#posted-comment-1', {
                                theme: 'bubble'
                            });
                            postedComment.disable();
                            postedComment.setContents(newComment.getContents());
                            $('.ql-tooltip').css('max-height', '0');
                        }
                    });
                }
            })
        });
    </script>
uloncl's avatar

@Sinnbeck app.js has

import 'quill/quill';
const Quill = require("quill");

window.Quill = Quill;

and this code is in a component but @vite is in app.blade.php so it is loaded on every view

Sinnbeck's avatar

@nebulous75 check the console for any other errors

Regarding css imports. Depends on your css type. Try @import '~quill/dist/quill.core.css'

uloncl's avatar

@Sinnbeck Failed to find '~quill/dist/quill.core.css' when i run npm run build

uloncl's avatar

@Sinnbeck ok well the only errors in the console are Uncaught ReferenceError: require is not defined and Uncaught ReferenceError: Quill is not defined

Please or to participate in this conversation.