Skip to content

Commit db671f1

Browse files
mathilde-marchandMathilde Marchand
andauthored
fix maj fonds sélectionnables (#386)
* fix maj fonds sélectionnables * fix code format * add empty option value --------- Co-authored-by: Mathilde Marchand <mathilde.marchand@sesan.fr>
1 parent b3d7c78 commit db671f1

1 file changed

Lines changed: 15 additions & 2 deletions

File tree

lib/mv.js

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -323,10 +323,23 @@ var mv = (function () {
323323
$(".bl." + classe + " input").bind("change", function (e) {
324324
var id = $(this).parent().parent().attr("data-layerid");
325325
var value = $(e.currentTarget).prop("checked");
326+
var select = $("#frm-bl-visible");
327+
var currentValue = select.val();
326328
if (value === true) {
327-
$("#frm-bl-visible option[value='" + id + "']").removeAttr("disabled");
329+
select.find("option[value='" + id + "']").removeAttr("disabled");
330+
if (!currentValue) {
331+
select.val(id).trigger("change");
332+
}
328333
} else {
329-
$("#frm-bl-visible option[value='" + id + "']").attr("disabled", "disabled");
334+
select.find("option[value='" + id + "']").attr("disabled", "disabled");
335+
if (id === currentValue) {
336+
var first = select.find("option:not(:disabled)").first();
337+
if (first.length) {
338+
select.val(first.val()).trigger("change");
339+
} else {
340+
select.val(null).trigger("change");
341+
}
342+
}
330343
}
331344
});
332345
},

0 commit comments

Comments
 (0)