<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Mifjs forum — Mif.Tree, Mif.Menu - serialize]]></title>
	<link rel="self" href="http://www.mifjs.net/forum/feed/atom/topic/46/"/>
	<updated>2008-09-07T22:08:20Z</updated>
	<generator>PunBB</generator>
	<id>http://mifjs.net/forum/topic/46/</id>
		<entry>
			<title type="html"><![CDATA[serialize]]></title>
			<link rel="alternate" href="http://mifjs.net/forum/post/160/#p160"/>
			<content type="html"><![CDATA[Hi,

Wrote a serialize function:
[code] 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;
     }
 });[/code]
So I can do this:
[code]     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));
     };[/code]
:)]]></content>
			<author>
				<name><![CDATA[elguapo]]></name>
				<uri>http://mifjs.net/forum/user/35/</uri>
			</author>
			<updated>2008-09-07T22:08:20Z</updated>
			<id>http://mifjs.net/forum/post/160/#p160</id>
		</entry>
</feed>

