Install of SELECT2

Need a little help.

I copied these lines into the head as described

<link href=“https://cdn.jsdelivr.net/npm/[email protected]/dist/css/select2.min.css” rel=“stylesheet” /> <script src=“https://cdn.jsdelivr.net/npm/[email protected]/dist/js/select2.min.js”></script>

(forgive the editors bolluxing of the content please)

Copied this into the html

<select class=“js-example-basic-multiple” name=“states[]” multiple=“multiple”> <option value=“AL”>Alabama</option> … <option value=“WY”>Wyoming</option> </select>

and this into

$(document).ready(function() {
$(’.js-example-basic-multiple’).select2();
});

but the result is a box with the values in it and not the appearance shown on the “Basic Usage” page. What have I done wrong?

Thank you,
Chris

It works fine when in a stand alone page, is it possible the class is found in another package somehow? Is there a way I can make the select unique so it doesn’t read from another class file?

Looks like this image

Rather than this

image

Uncaught TypeError: $(…).select2 is not a function
at HTMLDocument.

Hello? Posted a couple days ago and still seeking help

Did you also install jQuery? It’s a prerequisite for Select2, and its <script> tag must appear before the Select2 <script> tag.

Yes, jquery is loaded and working with other jquery functionality. You can see the results of the test at view-source:http://my.memoreebook.com/test6.php.

Hello again, jusr wondering if anyone has any ideas.

The same problem.

But the example is not the same text as in the html (there are no Timezone in bold).
Is there somewhere an instruction “how it should be in html, to be as in the example”

Found it.
That’s better for all who started to learn.

image
it’s ok

This appears to have nothing to do with my original question.

OK, I see that you’ve loaded jQuery and Select2, but your HTML (at test6.php) doesn’t contain a <select> element, nor does your JavaScript try to initialize a Select2 widget (either from a hard-coded <select> element in your HTML or via AJAX). Was the test6.php page meant to be a working example of your application? If not, please point me to an actual working page (one that at least includes the <select> element).

That was just a page to display jquery is loaded. the actual page is huge. I assumed the problem was with the css but I commented it all out and still see the same issue. I then moved all the css into the test page “http://my.memoreebook.com/test5.php” and it still works fine. There’s something in the page I’m trying to use this in that’s causing a problem. Any thoughts on what might cause a conflict?

P.S. Thanks for the help!

Sorry, but without seeing your actual code I don’t have any way of guessing what the problem might be.

The error message you originally posted occurs when you try to use Select2 without having loaded jQuery. Are you still getting that same error message?

If I get an answer to my other question about single select I’ll work the code back in and if it’s still not working I’ll definitely post the code here.

Good information thanks for sharing
VMware Engineer