Just to clarify:

My discussion with Stefan centered around getting serialize to seamlessly work with Rails' acts_as_nested_set.

That method has the following table structure by default:
 - parent_id
 - lft
 - rgt

Ideally, the HTML above would be serialized like:
item[1][parent_id]=0
item[1][lft]=1
item[1][rgt]=12
item[21][parent_id]=1
item[21][lft]=3
item[21][rgt]=4
item[34][parent_id]=1
item[34][lft]=5
item[34][rgt]=6
item[4][parent_id]=0
item[4][lft]=8
item[4][rgt]=9
item[7][parent_id]=0
item[7][lft]=10
item[7][rgt]=11

That will serialize to:
params[:item] = {1 => {:parent_id => 0, :lft => 1, :rgt => 12} ...}

So you could potentially do something like:

params[:item].each {|id, hash| Item.find(id).update_attributes(hash)}

Which should convert the serialized data into the acts_as_nested_set. Make sense?

-- Yehuda


On 10/29/06, Stefan Petre <[EMAIL PROTECTED]> wrote:
Philippe Jadin wrote:
> On 10/29/06, Stefan Petre <[EMAIL PROTECTED]> wrote:
>
>> I will use 4 days then release the plugin based on your feedback. Sure
>> later I can add more versions for serialization, but will be nice to
>> have them at the first release.
>>
>
>
> Maybe you could add explicit informations :
>
> item[1]['parent']=1        - parent id
> item[1]['level']=1        - level
> item[1]['left_id']=1        - left id
> item[1]['right_id']=6        - right id
> item[21]['parent']=1    - parent id
> item[21]['level']=2    - level
> item[21]['left_id']=2    - left id
> item[21]['right_id']=3    - right id
> [...]
>
>
I did it like so because Yehuda told me on Rails should be like that. I
need more input on this.

> Altough I wonder if we can trust the client code to give reliable
> left, right and level values. This would be very cool to have those
> left and right values. It takes a lot of time to rebuild a big nested
> set tree on the server side.
>
>
Why not. The DOM structure is a nested set. I think is easy to get the
right IDs

> Will it be possible to serialize only a part of the tree?
>
Never thought of that, but will be a very nice feature. But the hole
tree must be parsed because of the left and right IDs .
> Would it be possible to load tree nodes on demand ?
>
This is not the jogb for this plugin. You can do it your self and once
you insert the new items add them to the sortable
> Another detail, if an implementation doesn't allow to have something
> called 'root', it could be something like this :
>
> <ul id="item_0">
>    <li id="item_1">
>        <ul>
>            <li id="item_21"></li>
>            <li id="item_34"></li>
>        </ul>
>    </li>
>    <li id="item_4"></li>
>    <li id="item_7"></li>
> </ul>
>
> with this as a result :
> item[0]['parent']=false  (is false != 0? OTOH, the backend knows what
> is the id of root)
> item[1]['parent']=0
> item[21]['parent']=1
> item[34]['parent']=1
> item[4]['parent']=0
> item[7]['parent']=0
>
>
well, the root element has as parent it's own ID. I used ID root as a
habit because I always start with a node named root on my nested sets.

> My 2 cents :-)
>
Here is the change

_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/



--
Yehuda Katz
Web Developer | Wycats Designs
(ph)  718.877.1325
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/

Reply via email to