The error occured when trying to create a dmsf link. In such a case
select2 must be used in a javascript snippet after jquery and the
select2 plugin are loaded.
Adding the 'document ready' function ensures that everything is loaded
properly before the inline javascript will be executed.