How do I get select2 to work in IE8?


#1

I am having problems getting select2 to work in IE8.

I have multiple select drop downs and I am targeting them like:

$('select.form-control.select-dropdown').select2({
    placeholder: "Please select",
    allowHtml: true,
    closeOnSelect: true
});

Do I need to do anything special to get the selects to work in IE8?


#2

According to the Select2.org home page, they support IE8:

Support for both modern and legacy browsers is built-in, even including Internet Explorer 8.

Can you be more specific about the problem you’re having? Are there any messages in the JavaScript console?


#3

The error in the console is: undefined’ is null or not an object


#4

I have been trying to get select2 to work in IE8 for a while and unfortunately it won’t work. There are a few errors in the console:

Expected identifier, string or number on a test local install

It isn’t working out of the box and I cannot understand why?!

On my working project I get a different error:

undefined’ is null or not an object

Can anyone help?


#5

The console should show the file and line number where these errors occur. What are the lines of code where these errors happen?

Also, does your code work in other browsers? Other versions of IE? Chrome? Firefox?

Can you put your code on jsfiddle.net or codepen.io so I can see what’s happening?