Topic: serialize
Hi,
Wrote a serialize function:
Mif.Tree = new Class({
serialize: function(items){
var serial = [];
if (!items) items = this.root.getChildren();
items.each(function(el, i){
serial[i] = {
id: el.id,
children: (el.getChildren()) ? tree.serialize(el.getChildren()) : []
};
});
return serial;
}
});So I can do this:
var request = function() {
var theDump = tree.serialize();
var req = new Request({
method: 'post',
url: "save-list.php", onSuccess:
function(html) {
$('debug').empty().set('text',html);
}
}).send('m='+JSON.encode(theDump));
};![]()
Last edited by elguapo (2008-09-08 01:09:41)