Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision df8ecbfb

Von Moritz Bunkus vor fast 14 Jahren hinzugefügt

  • ID df8ecbfb2b88bab038b413d2ebcacc44e9cf7224
  • Vorgänger 38ef9063
  • Nachfolger 68879d96

Ausgewählte Elemente in hiddens verschicken lassen

Ansonsten werden nur die mitgeschickt, die momentan ausgewählt sind.

Unterschiede anzeigen:

js/jquery.multiselect2side.js
28 28
    return this.each(function () {
29 29
      var el = $(this);
30 30

  
31
      var hiddenName   = $(this).attr("name");
31 32
      var originalName = $(this).attr("name");
32 33
      if (originalName.indexOf('[') != -1)
33 34
        originalName = originalName.substring(0, originalName.indexOf('['));
34 35

  
35
      var nameDx = $(this).attr("name");
36
      var idDx   = originalName + "ms2side__dx";
37
      var nameSx = originalName + "ms2side__sx";
38
      var size   = $(this).attr("size");
36
      var nameDx   = originalName + "ms2side__dx";
37
      var idDx     = originalName + "ms2side__dx";
38
      var nameSx   = originalName + "ms2side__sx";
39
      var hiddenId = originalName + "ms2side_hidden";
40
      var size     = $(this).attr("size");
39 41
      $(this).attr("name", originalName + "ms2side__orig");
40 42
      // SIZE MIN
41 43
      if (size < 6) {
......
79 81
        (o.labeldx ? ("<div class='ms2side__header'>" + o.labeldx + "</div>") : "") +
80 82
        "<select title='" + o.labeldx + "' name='" + nameDx + "' id='" + idDx + "' size='" + size + "' multiple='multiple' ></select>" +
81 83
        "</div>" +
84
        "<span id=\"" + hiddenId + "\"></span>" +
82 85
        ((o.selectedPosition == 'right' && o.moveOptions) ? divUpDown : "") +
83 86
        "</div>";
84 87
      $(this).after(htmlToAdd).hide();
88
      $("#" + hiddenId).hide();
85 89

  
86 90
      // ELEMENTS
87 91
      var allSel    = $(this).next().find("select");
......
111 115
        var selectDx   = rightSel.children();
112 116
        var selectedSx = leftSel.find("option:selected");
113 117
        var selectedDx = rightSel.find("option:selected");
118
        var hiddenCont = $("#" + hiddenId);
114 119

  
115 120
        if (selectedSx.size() == 0 || (o.maxSelected >= 0 && (selectedSx.size() + selectDx.size()) > o.maxSelected))
116 121
          div.find(".AddOne").addClass('ms2side__hide');
......
142 147
        else
143 148
          div.find(".RemoveAll").removeClass('ms2side__hide');
144 149

  
150
        // Rebuild hidden inputs...
151
        hiddenCont.empty();
152
        rightSel.find("option").each(function(idx, option) {
153
          $('<input type="hidden"/>').attr("name", hiddenName).attr("value", $(option).attr("value")).appendTo(hiddenCont);
154
        });
155

  
145 156
        leftSel.sortOptions();
146 157
        rightSel.sortOptions();
147 158
      });

Auch abrufbar als: Unified diff