From 18f73b21b9b43de091cd6d925ce49afa0fb11ca4 Mon Sep 17 00:00:00 2001 From: Nathan Gray Date: Thu, 29 Sep 2011 19:20:20 +0000 Subject: [PATCH] Handling for setting value (for multiple-select) with an array or object --- etemplate/js/et2_widget_selectbox.js | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/etemplate/js/et2_widget_selectbox.js b/etemplate/js/et2_widget_selectbox.js index a4778d4476..0a9ef8cbaa 100644 --- a/etemplate/js/et2_widget_selectbox.js +++ b/etemplate/js/et2_widget_selectbox.js @@ -151,10 +151,27 @@ var et2_selectbox = et2_inputWidget.extend({ set_value: function(_value) { jQuery("option",this.input).attr("selected", false); this.value = _value; - if(jQuery("option[value='"+_value+"']", this.input).attr("selected", true).length == 0) + if(typeof _value == "array") { - et2_debug("warning", "Tried to set value that isn't an option", this, _value); -//console.trace(); + for(var i = 0; i < _value.length; i++) + { + jQuery("option[value='"+_value[i]+"']", this.input).attr("selected", true); + } + } + else if (typeof _value == "object") + { + for(var i in _value) + { + jQuery("option[value='"+_value[i]+"']", this.input).attr("selected", true); + } + } + else + { + if(jQuery("option[value='"+_value+"']", this.input).attr("selected", true).length == 0) + { + et2_debug("warning", "Tried to set value that isn't an option", this, _value); + //console.trace(); + } } },