From 89b7ddcb3281f76bef6d0cb29ea8d0c4817d40fa Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Tue, 4 Jun 2013 12:03:45 +0200 Subject: [PATCH] =?utf8?q?JS-Multiselect2Side:=20Namen=20der=20tempor?= =?utf8?q?=C3=A4ren=20Controls=20von=20Original-ID=20und=20nicht=20-Name?= =?utf8?q?=20ableiten?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Der Name ist nicht zwangsläufig eindeutig, vor allem, wenn mehrere Elemente dieser Art auf einer Seite vorhanden sind. Beispiel: name="client[].users[]" mehrfach in einer Schleife ausgegeben. --- js/jquery.multiselect2side.js | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/js/jquery.multiselect2side.js b/js/jquery.multiselect2side.js index e47a35fac..de74b6432 100644 --- a/js/jquery.multiselect2side.js +++ b/js/jquery.multiselect2side.js @@ -35,17 +35,19 @@ 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 = originalName + "ms2side__dx"; - var idDx = originalName + "ms2side__dx"; - var nameSx = originalName + "ms2side__sx"; - var hiddenId = originalName + "ms2side_hidden"; + var hiddenName = $(this).attr("name"); + var originalID = $(this).attr("id"); + if (!originalID) + originalID = hiddenName; + if (originalID.indexOf('[') != -1) + originalID = originalID.substring(0, originalID.indexOf('[')); + + var nameDx = originalID + "ms2side__dx"; + var idDx = originalID + "ms2side__dx"; + var nameSx = originalID + "ms2side__sx"; + var hiddenId = originalID + "ms2side_hidden"; var size = $(this).attr("size"); - $(this).attr("name", originalName + "ms2side__orig"); + $(this).attr("name", originalID + "ms2side__orig"); // SIZE MIN if (size < 6) { $(this).attr("size", "6"); -- 2.20.1