Add support for list-multi
authorFlorian Zeitz <florob@babelmonkeys.de>
Sun, 19 Dec 2010 01:57:06 +0000 (02:57 +0100)
committerFlorian Zeitz <florob@babelmonkeys.de>
Sun, 19 Dec 2010 01:57:06 +0000 (02:57 +0100)
js/main.js

index b634c9a16d4d6fb56f4e1da9c0f26e6bb3630f4d..955ceb9f5d9a0795529b5f9a9d577e134789b73c 100644 (file)
@@ -123,9 +123,10 @@ function addForm(elem, x) {
                 });
                 item.val(value);
             } else if (type == "list-multi") {
-                value = new Array();
-                $(this).find("value").each(function() {
-                    value[value.length] = $(this).text();
+                $(this).children("value").each(function() {
+                    item.children('option[value="' + $(this).text() + '"]').each(function() {
+                        $(this).attr("selected", "selected");
+                   });
                 });
             } else {
                 item.val($(this).find("value").text());
@@ -150,8 +151,8 @@ function serializeToDataform(form, st) {
         st.c("field", {"var": $(this).attr("name")});
         if (this.nodeName.toLowerCase() == "select" && this.multiple) {
             for (var i = 0; i < this.options.length; i++)
-                if (options[i].selected)
-                    st.c("value").t(options[i]).up();
+                if (this.options[i].selected)
+                    st.c("value").t(this.options[i].text).up();
         } else if (this.nodeName.toLowerCase() == "textarea") {
             var sp_value = this.value.split(/\r?\n|\r/g);
             for(var i = 0; i < sp_value.length; i++)