From df8ecbfb2b88bab038b413d2ebcacc44e9cf7224 Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Mon, 27 Dec 2010 14:01:30 +0100 Subject: [PATCH] =?utf8?q?Ausgew=C3=A4hlte=20Elemente=20in=20hiddens=20ver?= =?utf8?q?schicken=20lassen?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Ansonsten werden nur die mitgeschickt, die momentan ausgewählt sind. --- js/jquery.multiselect2side.js | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) 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(); }); -- 2.20.1