"query function not defined for Select2 undefined error"

Daniel Morris picture Daniel Morris · Jan 23, 2013 · Viewed 105.9k times · Source

Trying to use Select2 and getting this error on multiple item input/text field:

"query function not defined for Select2 undefined error"

Answer

Daniel Morris picture Daniel Morris · Jan 23, 2013

Covered in this google group thread

The problem was because of the extra div that was being added by the select2. Select2 had added new div with class "select2-container form-select" to wrap the select created. So the next time i loaded the function, the error was being thrown as select2 was being attached to the div element. I changed my selector...

Prefix select2 css identifier with specific tag name "select":

$('select.form-select').select2();