0

I need to use jQuery Steps plugin with Laravel. I have added jQuery and jQuery Steps via NPM this is my resources\js\app.js

import './bootstrap';

import jQuery from 'jquery';
window.$ = jQuery;

window.jQuery = jQuery


import 'jquery-steps/build/jquery.steps.min.js';

This is my view.

@vite(['resources/sass/app.scss', 'resources/js/app.js'])

<script type="module">
    $("#example-basic").steps({
        headerTag: "h3",
        bodyTag: "section",
        transitionEffect: "slideLeft",
        autoFocus: true
    });
 </script>

But getting this error.

Uncaught ReferenceError: jQuery is not defined at app-0acac567.js:23:13949

3
  • Did you try to move the bootstrap import after the jQuery one? With the type=module, can you try jQuery("#example-basic") instead of $, in line with the import jQuery line. Commented Sep 24, 2023 at 21:48
  • @Greg Thanks for the response but unfortunately didn't work :'( Commented Sep 24, 2023 at 21:59
  • How about: import {jQuery} from 'jquery'; window.$ = window.jQuery = jQuery; There's a lengthy thread here: stackoverflow.com/questions/41800122/… Commented Sep 24, 2023 at 22:24

1 Answer 1

0

I had to use it like this in app.js

import('jquery-steps/build/jquery.steps.min.js').then(() => {
    $(document).ready(function () {
        $('#example-basic').steps({
            headerTag: 'h3',
            bodyTag: 'section',
            transitionEffect: 'slideLeft',
            autoFocus: true
        });
    });
});
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.