sorting data at parsing for consistent editing

handle blank input in editor (return default value)
This commit is contained in:
jean-emmanuel 2015-11-04 08:59:11 +01:00
parent e9f458d258
commit 5e7a90bc5b
2 changed files with 9 additions and 3 deletions

View file

@ -72,8 +72,9 @@ enableEditor = function(){
`)
input.appendTo(form)
input.on('change',function(){
var v = $(this).data('type') == 'object'?JSON.parse($(this).val()):$(this).val()
var v = $(this).val()!= '' && $(this).data('type') == 'object'?JSON.parse($(this).val()):$(this).val()
data[$(this).attr('title')]= v=='true'||v=='false'?eval(v):v
if (v=='') delete data[$(this).attr('title')]
updateWidget()
})
@ -185,8 +186,9 @@ enableEditor = function(){
`)
input.appendTo(form)
input.on('change',function(){
var v = $(this).data('type') == 'object'?JSON.parse($(this).val()):$(this).val()
var v = $(this).val()!= '' && $(this).data('type') == 'object'?JSON.parse($(this).val()):$(this).val()
data[$(this).attr('title')]= v=='true'||v=='false'?eval(v):v
if (v=='') delete data[$(this).attr('title')]
updateSession()
})

View file

@ -96,7 +96,11 @@ parsewidgets = function(widgets,parent) {
style = styleW + ';' + styleH
for (k in widgetOptions[widgetData.type]) {
var tmp = widgetData[k]
delete widgetData[k]
widgetData[k] = tmp
}