Borrowed from the Bootstrap doc implementation.
This also adds the `select2` function back to jQuery, so you can still initialize Select2 using the old syntax.