From c61edf2757c92c0460b9e0581771f7a9b06ed1ba Mon Sep 17 00:00:00 2001 From: Florian Zeitz Date: Sun, 19 Dec 2010 02:57:06 +0100 Subject: [PATCH] Add support for list-multi --- js/main.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/js/main.js b/js/main.js index b634c9a..955ceb9 100644 --- a/js/main.js +++ b/js/main.js @@ -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++) -- 2.39.2