Skip to content

Instantly share code, notes, and snippets.

@yehudah
Created May 3, 2015 09:49
Show Gist options
  • Select an option

  • Save yehudah/47fe3d28b3d2614e6aa8 to your computer and use it in GitHub Desktop.

Select an option

Save yehudah/47fe3d28b3d2614e6aa8 to your computer and use it in GitHub Desktop.
fix select2 plugin inside jquery ui dialog
dialog = $( "#dialog-form" ).dialog({
autoOpen: true,
height: 300,
width: 450,
modal: true,
open: function () {
if ($.ui && $.ui.dialog && $.ui.dialog.prototype._allowInteraction) {
var ui_dialog_interaction = $.ui.dialog.prototype._allowInteraction;
$.ui.dialog.prototype._allowInteraction = function(e) {
if ($(e.target).closest('.select2-dropdown').length) return true;
return ui_dialog_interaction.apply(this, arguments);
};
}
},
_allowInteraction: function (event) {
return !!$(event.target).is(".select2-input") || this._super(event);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment