Fix remove param htmlid in ajax_combobox
This commit is contained in:
parent
aea6a8f9ec
commit
ac20a1a874
@ -135,6 +135,8 @@ class FormProjets
|
|||||||
|
|
||||||
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
|
||||||
|
|
||||||
|
if (empty($htmlid)) $htmlid = $htmlname;
|
||||||
|
|
||||||
$out='';
|
$out='';
|
||||||
$outarray=array();
|
$outarray=array();
|
||||||
|
|
||||||
@ -175,14 +177,14 @@ class FormProjets
|
|||||||
if (! empty($conf->use_javascript_ajax))
|
if (! empty($conf->use_javascript_ajax))
|
||||||
{
|
{
|
||||||
include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php';
|
include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php';
|
||||||
$comboenhancement = ajax_combobox($htmlname, array(), 0, $forcefocus,'resolve',$htmlid);
|
$comboenhancement = ajax_combobox($htmlid, array(), 0, $forcefocus);
|
||||||
$out.=$comboenhancement;
|
$out.=$comboenhancement;
|
||||||
$nodatarole=($comboenhancement?' data-role="none"':'');
|
$nodatarole=($comboenhancement?' data-role="none"':'');
|
||||||
$minmax='minwidth100 maxwidth300';
|
$minmax='minwidth100 maxwidth300';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($option_only)) {
|
if (empty($option_only)) {
|
||||||
$out.= '<select class="flat'.($minmax?' '.$minmax:'').'"'.($disabled?' disabled="disabled"':'').' id="'.(empty($htmlid)?$htmlname:$htmlid).'" name="'.$htmlname.'"'.$nodatarole.'>';
|
$out.= '<select class="flat'.($minmax?' '.$minmax:'').'"'.($disabled?' disabled="disabled"':'').' id="'.$htmlid.'" name="'.$htmlname.'"'.$nodatarole.'>';
|
||||||
}
|
}
|
||||||
if (!empty($show_empty)) {
|
if (!empty($show_empty)) {
|
||||||
$out.= '<option value="0"> </option>';
|
$out.= '<option value="0"> </option>';
|
||||||
|
|||||||
@ -357,14 +357,12 @@ function ajax_dialog($title,$message,$w=350,$h=150)
|
|||||||
* @param int $minLengthToAutocomplete Minimum length of input string to start autocomplete
|
* @param int $minLengthToAutocomplete Minimum length of input string to start autocomplete
|
||||||
* @param int $forcefocus Force focus on field
|
* @param int $forcefocus Force focus on field
|
||||||
* @param string $widthTypeOfAutocomplete 'resolve' or 'off'
|
* @param string $widthTypeOfAutocomplete 'resolve' or 'off'
|
||||||
* @param int $htmlid Html id to use instead of htmlname
|
|
||||||
* @return string Return html string to convert a select field into a combo, or '' if feature has been disabled for some reason.
|
* @return string Return html string to convert a select field into a combo, or '' if feature has been disabled for some reason.
|
||||||
*/
|
*/
|
||||||
function ajax_combobox($htmlname, $events=array(), $minLengthToAutocomplete=0, $forcefocus=0, $widthTypeOfAutocomplete='resolve',$htmlid='')
|
function ajax_combobox($htmlname, $events=array(), $minLengthToAutocomplete=0, $forcefocus=0, $widthTypeOfAutocomplete='resolve')
|
||||||
{
|
{
|
||||||
global $conf;
|
global $conf;
|
||||||
|
|
||||||
if (empty($htmlid)) $htmlid = $htmlname;
|
|
||||||
if (! empty($conf->browser->phone)) return ''; // select2 disabled for smartphones with standard browser (does not works, popup appears outside screen)
|
if (! empty($conf->browser->phone)) return ''; // select2 disabled for smartphones with standard browser (does not works, popup appears outside screen)
|
||||||
if (! empty($conf->dol_use_jmobile)) return ''; // select2 works with jmobile but it breaks the autosize feature of jmobile.
|
if (! empty($conf->dol_use_jmobile)) return ''; // select2 works with jmobile but it breaks the autosize feature of jmobile.
|
||||||
if (! empty($conf->global->MAIN_DISABLE_AJAX_COMBOX)) return '';
|
if (! empty($conf->global->MAIN_DISABLE_AJAX_COMBOX)) return '';
|
||||||
@ -373,10 +371,10 @@ function ajax_combobox($htmlname, $events=array(), $minLengthToAutocomplete=0, $
|
|||||||
if (empty($minLengthToAutocomplete)) $minLengthToAutocomplete=0;
|
if (empty($minLengthToAutocomplete)) $minLengthToAutocomplete=0;
|
||||||
|
|
||||||
$tmpplugin='select2';
|
$tmpplugin='select2';
|
||||||
$msg='<!-- JS CODE TO ENABLE '.$tmpplugin.' for id '.$htmlid.' -->
|
$msg='<!-- JS CODE TO ENABLE '.$tmpplugin.' for id '.$htmlname.' -->
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
$(\''.(preg_match('/^\./',$htmlid)?$htmlid:'#'.$htmlid).'\').'.$tmpplugin.'({
|
$(\''.(preg_match('/^\./',$htmlname)?$htmlname:'#'.$htmlname).'\').'.$tmpplugin.'({
|
||||||
dir: \'ltr\',
|
dir: \'ltr\',
|
||||||
width: \''.$widthTypeOfAutocomplete.'\', /* off or resolve */
|
width: \''.$widthTypeOfAutocomplete.'\', /* off or resolve */
|
||||||
minimumInputLength: '.$minLengthToAutocomplete.'
|
minimumInputLength: '.$minLengthToAutocomplete.'
|
||||||
@ -387,17 +385,17 @@ function ajax_combobox($htmlname, $events=array(), $minLengthToAutocomplete=0, $
|
|||||||
if (count($events))
|
if (count($events))
|
||||||
{
|
{
|
||||||
$msg.= '
|
$msg.= '
|
||||||
jQuery("#'.$htmlid.'").change(function () {
|
jQuery("#'.$htmlname.'").change(function () {
|
||||||
var obj = '.json_encode($events).';
|
var obj = '.json_encode($events).';
|
||||||
$.each(obj, function(key,values) {
|
$.each(obj, function(key,values) {
|
||||||
if (values.method.length) {
|
if (values.method.length) {
|
||||||
runJsCodeForEvent'.$htmlid.'(values);
|
runJsCodeForEvent'.$htmlname.'(values);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
function runJsCodeForEvent'.$htmlid.'(obj) {
|
function runJsCodeForEvent'.$htmlname.'(obj) {
|
||||||
var id = $("#'.$htmlid.'").val();
|
var id = $("#'.$htmlname.'").val();
|
||||||
var method = obj.method;
|
var method = obj.method;
|
||||||
var url = obj.url;
|
var url = obj.url;
|
||||||
var htmlname = obj.htmlname;
|
var htmlname = obj.htmlname;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user