Welcome to the Lobeo Module Server project. Please feel free to submit bugs related to it.
FS#273 - easy method to persist data from javascript
Attached to Project:
LMS
Opened by Ferdinand (PaGaisu) - Friday, 09 December 2011, 13:32 GMT
Last edited by Ferdinand (PaGaisu) - Wednesday, 21 December 2011, 14:05 GMT
Opened by Ferdinand (PaGaisu) - Friday, 09 December 2011, 13:32 GMT
Last edited by Ferdinand (PaGaisu) - Wednesday, 21 December 2011, 14:05 GMT
|
DetailsEasy method to persist data from javascript:
2 methods: resolve and persist Accepted data types: string/number/boolean/array resolve takes the name of variable as single parameter Example: resolve('toto'); toto will hold the value coming from the DB or undefined if it's not found persist takes the name of variable as single parameter Example: persist('toto'); The value of toto will be persisted in the DB //////////////////////////////////////////////// function resolve(variable){ eval(variable+'=35;'); } function persist(variable){ eval(variable+'=1;'); } //////////////////////////////////////////////// Mozilla got the very interesting toSource() available on all the object. Why not use this ? |
This task depends upon
Closed by Ferdinand (PaGaisu)
Wednesday, 21 December 2011, 14:05 GMT
Reason for closing: Implemented
Wednesday, 21 December 2011, 14:05 GMT
Reason for closing: Implemented
require('com.lobeo.lms.Persistence');
Persistence.resolve('toto');
if(toto==undefined)
toto = 10;
Persistence.persist('toto');
require('com.lobeo.lms.Persistence');
//persist
Persistence.persist('toto',function() {print('toto');});
//resolve
var funToto = Persistence.resolve('toto');
funToto();