This extension is designed for adding custom buttons to jQuery's dialogs titlebar. Just add a reference to the script 'jquery.ui.dialog.js', after the place where is ...
As per discussion with Scott Gonzalez here, since Select2's dropdown is always appended directly to the document body, it isn't registered as a valid interaction target when inside of a modal Dialog.