Select2 jquery in asp.net not triggering

I have been tinkering with the Select2 for a dropdownlist and a select. I've been trying numerous examples. And I can't get them to recognize the select2 aspect of jquery.

I saw I need to include the select2 css and js. Which I just took out those two files from the dist folder from the download. That didn't work. So I thought maybe there was someting in the sub folders it required, so I pointed to those files in the downloaded, complete folder.

Question 1:
Do I need all those downloaded folders or just the two files from those folders? I took them from the /dist/css and /dist/js folders.

Question 2:
I am attaching the "view" source" of my asp.net page. Can you see something I'm missing? Yes, I did test the paths and tried a complete path to make sure I was finding it, and it does exist in the path. But still it's not using the select2 styles or the js.

select2Example.html

In this last example, I did the js using the class values:
            $('.js-example-basic-single').select2({
                placeholder: "[Select]",
                multiple: true,
                allowClear: true
            });

Open in new window


However, I had previously tried loading it by the ID of the control with clientidmode="Static" and with it not static:

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

            $("#<%=lstJobs.ClientID%>").select2({
            placeholder: "[Select]",
            multiple: true,
            allowClear: true
        });

.... snip

    });
    </script>


Thanks!
LVL 2
Starr DuskkASP.NET VB.NET DeveloperAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ste5anSenior DeveloperCommented:
For debugging: Test whether $("#<%=lstJobs.ClientID%>") returns something or not.

From the design perspective: In many cases the selector should be static, e.g. a class.

Otherwise post your rendered HTML. The attached file is unreadable.
0
Starr DuskkASP.NET VB.NET DeveloperAuthor Commented:
I didn't realize the chrome gorped that when I saved it as an html file.

In the process of manually creating an html version, I realized it is working. Now I just have to see where it isn't working in my code.
Thanks for the advice!
0
Starr DuskkASP.NET VB.NET DeveloperAuthor Commented:
I figured out I was using the wrong command to register the js file.

It should have been this style:
 <script type='text/javascript' src='../../Layout/JS/jquery-3.2.1.min.js'></script><link href="../../Layout/CSS/Controls/Select2/Select2.css" type="text/css" rel="stylesheet" /><script type='text/javascript' src='../../Layout/JS/Select2.min.js'></script>

and I was registering it using a link instead.

And wow. I can't get over what Chrome did to my save as. It is so unreadable.

thanks for the feedback which put me on the right path!
0
Starr DuskkASP.NET VB.NET DeveloperAuthor Commented:
see above.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.