diff --git a/htdocs/core/lib/ajax.lib.php b/htdocs/core/lib/ajax.lib.php index 2ddc7125d4a..a558d97569f 100644 --- a/htdocs/core/lib/ajax.lib.php +++ b/htdocs/core/lib/ajax.lib.php @@ -386,10 +386,11 @@ function ajax_autoselect($htmlname, $addlink='') * @param int $minLengthToAutocomplete Minimum length of input string to start autocomplete * @param int $forcefocus Force focus on field * @param string $widthTypeOfAutocomplete 'resolve' or 'off' + * @param string $modalid ID of modal (for avoid focus problem when select2 is in a modal dialog window) * @return string Return html string to convert a select field into a combo, or '' if feature has been disabled for some reason. * @see selectArrayAjax of html.form.class */ -function ajax_combobox($htmlname, $events=array(), $minLengthToAutocomplete=0, $forcefocus=0, $widthTypeOfAutocomplete='resolve') +function ajax_combobox($htmlname, $events=array(), $minLengthToAutocomplete=0, $forcefocus=0, $widthTypeOfAutocomplete='resolve', $modalid='dialog-confirm') { global $conf; @@ -425,7 +426,8 @@ function ajax_combobox($htmlname, $events=array(), $minLengthToAutocomplete=0, $ }, escapeMarkup: function(markup) { return markup; - } + }, + dropdownParent: $(\'#'.$modalid.'\') })'; if ($forcefocus) $msg.= '.select2(\'focus\')'; $msg.= ';'."\n";