Fix #15371
Extrafields from type "select" depending on other fields not working in Safari & jquery select2 #15371
This commit is contained in:
parent
754a9778ea
commit
2da8fb75a8
@ -6976,34 +6976,37 @@ abstract class CommonObject
|
|||||||
if (!empty($conf->use_javascript_ajax)) {
|
if (!empty($conf->use_javascript_ajax)) {
|
||||||
$out .= '
|
$out .= '
|
||||||
<script>
|
<script>
|
||||||
jQuery(document).ready(function() {
|
jQuery(document).ready(function() {
|
||||||
function showOptions(child_list, parent_list)
|
function showOptions(child_list, parent_list, orig_select)
|
||||||
{
|
{
|
||||||
var val = $("select[name=\""+parent_list+"\"]").val();
|
var val = $("select[name=\""+parent_list+"\"]").val();
|
||||||
var parentVal = parent_list + ":" + val;
|
var parentVal = parent_list + ":" + val;
|
||||||
if(val > 0) {
|
if(val > 0) {
|
||||||
$("select[name=\""+child_list+"\"] option[parent]").hide();
|
var options = orig_select.find("option[parent=\""+parentVal+"\"]").clone();
|
||||||
$("select[name=\""+child_list+"\"] option[parent=\""+parentVal+"\"]").show();
|
$("select[name=\""+child_list+"\"] option[parent]").remove();
|
||||||
} else {
|
$("select[name=\""+child_list+"\"]").append(options);
|
||||||
$("select[name=\""+child_list+"\"] option").show();
|
} else {
|
||||||
}
|
var options = orig_select.find("option[parent]").clone();
|
||||||
}
|
$("select[name=\""+child_list+"\"] option[parent]").remove();
|
||||||
function setListDependencies() {
|
$("select[name=\""+child_list+"\"]").append(options);
|
||||||
jQuery("select option[parent]").parent().each(function() {
|
|
||||||
var child_list = $(this).attr("name");
|
|
||||||
var parent = $(this).find("option[parent]:first").attr("parent");
|
|
||||||
var infos = parent.split(":");
|
|
||||||
var parent_list = infos[0];
|
|
||||||
showOptions(child_list, parent_list);
|
|
||||||
|
|
||||||
$("select[name=\""+parent_list+"\"]").change(function() {
|
|
||||||
showOptions(child_list, parent_list);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
function setListDependencies() {
|
||||||
|
jQuery("select option[parent]").parent().each(function() {
|
||||||
|
var orig_select = {};
|
||||||
|
var child_list = $(this).attr("name");
|
||||||
|
orig_select [child_list] = $(this).clone();
|
||||||
|
var parent = $(this).find("option[parent]:first").attr("parent");
|
||||||
|
var infos = parent.split(":");
|
||||||
|
var parent_list = infos[0];
|
||||||
|
$("select[name=\""+parent_list+"\"]").change(function() {
|
||||||
|
showOptions(child_list, parent_list, orig_select [child_list]);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
setListDependencies();
|
setListDependencies();
|
||||||
});
|
});
|
||||||
</script>'."\n";
|
</script>'."\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user