From 7842a14946a4e198542268e3a8b1f7e96c56235b Mon Sep 17 00:00:00 2001 From: Lukas Mueller Date: Tue, 3 Dec 2013 09:05:43 -0500 Subject: [PATCH] fix list creation for Internet Explorer. --- js/CXGN/List.js | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/js/CXGN/List.js b/js/CXGN/List.js index 37ea142f7..f47f6b42a 100644 --- a/js/CXGN/List.js +++ b/js/CXGN/List.js @@ -406,8 +406,10 @@ CXGN.List.prototype = { return list_item_id; }, - // deprecated addToList: function(list_id, text) { + if (! text) { + return; + } var list = text.split("\n"); var duplicates = []; @@ -631,7 +633,9 @@ function addToListMenu(listMenuDiv, dataDiv, options) { } if (options.typeSourceDiv) { type = getData(options.typeSourceDiv, selectText); - type = type.replace(/(\n|\r)+$/, ''); + if (type) { + type = type.replace(/(\n|\r)+$/, ''); + } } if (options.types) { type = options.listType; @@ -692,16 +696,34 @@ function addToListMenu(listMenuDiv, dataDiv, options) { } - function getData(id, selectText) { var divType = jQuery("#"+id).get(0).tagName; var data; - if (divType == 'DIV' || divType =='SPAN' || divType === undefined) { + if (divType == 'DIV' || divType =='SPAN' || divType === undefined) { data = jQuery('#'+id).html(); } if (divType == 'SELECT' && selectText) { - data = jQuery('#'+id+" option:selected").text(); + if (jQuery.browser.msie) { + // Note: MS IE unfortunately removes all whitespace + // in the jQuery().text() call. Program it out... + // + var selectbox = document.getElementById(id); + var datalist = new Array(); + for (var n=0; n