From: Moritz Bunkus Date: Mon, 27 Dec 2010 13:01:30 +0000 (+0100) Subject: Ausgewählte Elemente in hiddens verschicken lassen X-Git-Tag: release-2.6.2beta1~64^2~15 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=df8ecbfb2b88bab038b413d2ebcacc44e9cf7224;p=kivitendo-erp.git Ausgewählte Elemente in hiddens verschicken lassen Ansonsten werden nur die mitgeschickt, die momentan ausgewählt sind. --- diff --git a/js/jquery.multiselect2side.js b/js/jquery.multiselect2side.js index 00ebe9b29..250fce74f 100644 --- a/js/jquery.multiselect2side.js +++ b/js/jquery.multiselect2side.js @@ -28,14 +28,16 @@ return this.each(function () { var el = $(this); + var hiddenName = $(this).attr("name"); var originalName = $(this).attr("name"); if (originalName.indexOf('[') != -1) originalName = originalName.substring(0, originalName.indexOf('[')); - var nameDx = $(this).attr("name"); - var idDx = originalName + "ms2side__dx"; - var nameSx = originalName + "ms2side__sx"; - var size = $(this).attr("size"); + var nameDx = originalName + "ms2side__dx"; + var idDx = originalName + "ms2side__dx"; + var nameSx = originalName + "ms2side__sx"; + var hiddenId = originalName + "ms2side_hidden"; + var size = $(this).attr("size"); $(this).attr("name", originalName + "ms2side__orig"); // SIZE MIN if (size < 6) { @@ -79,9 +81,11 @@ (o.labeldx ? ("
" + o.labeldx + "
") : "") + "" + "" + + "" + ((o.selectedPosition == 'right' && o.moveOptions) ? divUpDown : "") + ""; $(this).after(htmlToAdd).hide(); + $("#" + hiddenId).hide(); // ELEMENTS var allSel = $(this).next().find("select"); @@ -111,6 +115,7 @@ var selectDx = rightSel.children(); var selectedSx = leftSel.find("option:selected"); var selectedDx = rightSel.find("option:selected"); + var hiddenCont = $("#" + hiddenId); if (selectedSx.size() == 0 || (o.maxSelected >= 0 && (selectedSx.size() + selectDx.size()) > o.maxSelected)) div.find(".AddOne").addClass('ms2side__hide'); @@ -142,6 +147,12 @@ else div.find(".RemoveAll").removeClass('ms2side__hide'); + // Rebuild hidden inputs... + hiddenCont.empty(); + rightSel.find("option").each(function(idx, option) { + $('').attr("name", hiddenName).attr("value", $(option).attr("value")).appendTo(hiddenCont); + }); + leftSel.sortOptions(); rightSel.sortOptions(); });