From e4a4154f3fb86f8e87ddb782d7aea292068538e8 Mon Sep 17 00:00:00 2001 From: Nathan Gray Date: Thu, 22 Mar 2012 23:19:13 +0000 Subject: [PATCH] Shuffle where to look for options: first by ID, then top level, then in row --- etemplate/js/et2_widget_selectbox.js | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/etemplate/js/et2_widget_selectbox.js b/etemplate/js/et2_widget_selectbox.js index 1a8d061cb9..246d3c5070 100644 --- a/etemplate/js/et2_widget_selectbox.js +++ b/etemplate/js/et2_widget_selectbox.js @@ -110,11 +110,23 @@ var et2_selectbox = et2_inputWidget.extend({ // Try to find the options inside the "sel-options" array if(this.getArrayMgr("sel_options")) { - // Select options tend to be defined once, at the top level, so try that first - var content_options = this.getArrayMgr("sel_options").getRoot().getEntry(name_parts[name_parts.length-1]); + var content_options = {}; - // Try again according to ID, but strip any encoded ][ - if(!content_options) content_options = this.getArrayMgr("sel_options").getEntry(this.id.replace(/[/g,'[').replace(/]/g,']')); + // Try first according to ID + content_options = this.getArrayMgr("sel_options").getEntry(this.id); + + // Select options tend to be defined once, at the top level, so try that first + if(!content_options) + { + content_options = this.getArrayMgr("sel_options").getRoot().getEntry(name_parts[name_parts.length-1]); + } + + // Maybe in a row, and options got stuck in ${row} instead of top level + if(!content_options && this.getArrayMgr("sel_options").perspectiveData.row) + { + var row_id = this.id.replace(/[0-9]+/,'${row}'); + content_options = this.getArrayMgr("sel_options").getEntry(row_id); + } if(_attrs["select_options"] && content_options) { _attrs["select_options"] = jQuery.extend({},_attrs["select_options"],content_options);