fgcommand.js: allow setting of multiple properties
extend setPropertyValue(path,value,callback,context) if value is 'just a value': set value of property named by path if value is object, assume JsonProperty(ies) and set the entire tree if callback is set, callback gets called after to POST succeeded if context is set, 'this' is set for the callback
This commit is contained in:
parent
8872ca7083
commit
778f056fd8
1 changed files with 28 additions and 4 deletions
|
@ -186,11 +186,35 @@
|
|||
});
|
||||
},
|
||||
|
||||
setPropertyValue : function(path, value) {
|
||||
setPropertyValue : function(path, value, callback, context) {
|
||||
if( value == null )
|
||||
return;
|
||||
|
||||
var url = "/json/" + path;
|
||||
switch( typeof(value) ) {
|
||||
case 'number':
|
||||
case 'string':
|
||||
case 'boolean':
|
||||
jquery.post(url, JSON.stringify({
|
||||
'value' : value
|
||||
}));
|
||||
})).done(function(data){
|
||||
if( !callback ) return;
|
||||
if (context) callback.call(context, data.value);
|
||||
else callback(data.value);
|
||||
});
|
||||
return;
|
||||
|
||||
case 'object':
|
||||
jquery.post(url, JSON.stringify(value)).done(function(data){
|
||||
if( !callback ) return;
|
||||
if (context) callback.call(context, data.value);
|
||||
else callback(data.value);
|
||||
});
|
||||
return;
|
||||
|
||||
default:
|
||||
return;
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue