Selectize.js: Javascript error

Created on 20 Aug 2020  ·  10Comments  ·  Source: selectize/selectize.js

With this code:

    <script type="text/javascript" src="/static/infraestructura/selectize.min.js"></script>
    <link rel="stylesheet" type="text/css" href="/static/infraestructura/selectize.default.css" />
    <script>
    ('#input-tags').selectize({
        delimiter: ',',
        persist: false,
        create: function(input) {
        return {
            value: input,
            text: input
        }
        }
    });
    </script>

I received a strange error (see shot)

Captura de pantalla_2020-08-20_22-25-05

Most helpful comment

You will get jQuery installed automatically, as peer dependency, if you use NPM version 1 or 2 (see UPDATE: note at the bottom of this explanation).
So no change for really old projects.

When having NPM version 3, then the dependency needs to be explicitly installed, manually, since peerDependencies are not handled but they just throw a WARNing (that IMHO should really be an ERRor).

This could probably be made more clear into the README.

All 10 comments

I may be stupid, but isn't jquery required?

But you say in Installation that select.js has jquery.

And which version?

@somenxavier Where does it say that? It says only that it is an dependency.
You can use the current version of jQuery.

You are also missing the jQuery or $ name before your brackets:

Should be $('#input-tags') or jQuery('#input-tags')

But you say in Installation that select.js has jquery.

@somenxavier jquery is a required dependency, but is not included. The latest version is recommended

You will get jQuery installed automatically, as peer dependency, if you use NPM version 1 or 2 (see UPDATE: note at the bottom of this explanation).
So no change for really old projects.

When having NPM version 3, then the dependency needs to be explicitly installed, manually, since peerDependencies are not handled but they just throw a WARNing (that IMHO should really be an ERRor).

This could probably be made more clear into the README.

Thanks.

Put in it: https://github.com/selectize/selectize.js/blob/master/docs/usage.md
and mention the version needed.

I think that Usage is more about domain-related details; while in README is more environment-related, with details about dependencies, installation, package-managers.

Specifically, this issue is related to NPM's behaviour; the user is supposed to know these version differences already by themselves; it really isn't about Selectize.

But ☝🏻 I think a hint in the README already helps a lot, when the user doesn't know NPM; there is also already an example of the installation of a jQuery version; although for specific decisions one should refer to the semver in the package.json.

IMHO the merge-request from 3 comments ago should be enough.
Of course you can submit a PR if you think that something can be improved; Selectize is maintained just by the community nowadays.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

eliashdezr picture eliashdezr  ·  41Comments

andreypopp picture andreypopp  ·  15Comments

CarlosLlongo picture CarlosLlongo  ·  18Comments

AndyBean picture AndyBean  ·  15Comments

Wardrop picture Wardrop  ·  19Comments