Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

window.Filterizr is not a constructor OR Uncaught SyntaxError: import declarations may only appear at top level of a module OR Uncaught (in promise) TypeError: Filterizr is not a constructor #190

Open
o-bardiuk opened this issue Oct 25, 2024 · 0 comments
Labels

Comments

@o-bardiuk
Copy link

o-bardiuk commented Oct 25, 2024

I get some of these errors from Getting started page

import Filterizr from 'filterizr'

// Configure your options
const options = { /* check next step for available options */ };

// Adjust the CSS selector to match the container where
// you set up your image gallery
const filterizr = new Filterizr('.filter-container', options);

Uncaught SyntaxError: import declarations may only appear at top level of a module

If I copy paste code from the demo I get "window.Filterizr is not a constructor "

If I tweak the code like so I get:

<script src="filterizr.min.js" type="module"></script>
<script>

    async function main() {
        const Filterizr = await import("./filterizr.min.js");
        const filterizr = new Filterizr('.filter-container');
    }

    main();

</script>

Uncaught (in promise) TypeError: Filterizr is not a constructor

How do I use it in a normal way without NPM?

<script src="vanilla.filterizr.min.js"></script>
<script>

    Filterizr('.filter-container');

</script>
Uncaught TypeError: this is undefined
    t http://localhost:8000/vanilla.filterizr.min.js:1
<script
        src="https://code.jquery.com/jquery-3.4.1.min.js"
        integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo="
        crossorigin="anonymous"
></script>
<script src="jquery.filterizr.min.js"></script>
<script>

    window.Filterizr('.filter-container');

</script>

Uncaught TypeError: t.shuffle is undefined

What am I doing wrong?

@o-bardiuk o-bardiuk added the bug label Oct 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant