summaryrefslogtreecommitdiff
path: root/views/js/editable.js
diff options
context:
space:
mode:
Diffstat (limited to 'views/js/editable.js')
-rw-r--r--views/js/editable.js63
1 files changed, 12 insertions, 51 deletions
diff --git a/views/js/editable.js b/views/js/editable.js
index 353c576..e4eb68f 100644
--- a/views/js/editable.js
+++ b/views/js/editable.js
@@ -25,50 +25,30 @@
if (typeof options.type == "string") opt['type'] = options.type;
- if (options.type == "select" && typeof options.data == "string")
- {
-
- var ar = [];
- var arData = jQuery.parseJSON(options.data);
- var strValue = jQuery(this).html();
- var value = 0;
-
- for (var i in arData)
- {
-
- ar.push( { 'value': i, 'text': arData[i] } );
- if (arData[i] == strValue) value = i;
-
- }
-
- // Normale Übergabe eines JSON Strings
- opt.source = ar;
- opt.type = 'select';
- opt.value = value;
-
- }
- else if (options.type == "select" && typeof options.data == "object")
+ if (options.type == "select" && Array.isArray(options.data))
{
-
- var value = 0;
+
+ var value = "0";
var strValue = jQuery(this).html();
for (var i in options.data)
{
-
- if (options.data[i] == strValue) value = i;
+
+ if (options.data[i].text == strValue) value = options.data[i].value;
}
opt.source = options.data;
- opt.value = value
+ opt.type = 'select';
+ opt.value = value;
- }
+ }
else if (options.type == 'multiarray')
{
var ar = [];
var arData = jQuery.parseJSON(options.data);
+ var strValue = jQuery(this).html();
for (var i in arData)
{
@@ -80,6 +60,8 @@
objData['children'].push( { 'value': j, 'text': arData[i]['fields'][j] } );
+ if (arData[i]['fields'][j] == strValue) value = j;
+
}
ar.push(objData);
@@ -88,29 +70,8 @@
opt.source = ar;
opt.type = 'select';
+ opt.value = j;
- }
- else if (options.type == 'string' && typeof options.data == "string")
- {
-
- var ar = [];
- var arData = jQuery.parseJSON(options.data);
-
- for (var i in arData)
- {
-
- ar.push( {
- 'value': i,
- 'text': arData[i]
- } );
-
- if (arData[i] == jQuery(this).text()) opt.value = i;
-
- }
-
- opt.type = 'select';
- opt.source = ar;
-
}
else
{