Created
June 8, 2011 07:41
-
-
Save ramontayag/1013977 to your computer and use it in GitHub Desktop.
serialize.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
serialize: function(o) { | |
o = o || {}; | |
var ret = []; | |
$(this.element).children('li').each(function() { _recursiveItems($(this)); }); | |
return ret.join("&"); | |
function _recursiveItems(li) { | |
var id = li.attr("id"); | |
var parentId = 'root'; | |
var parent = li.parent(o.listType).parent('li'); | |
if (parent.length > 0) { | |
parentId = parent.attr('id'); | |
} | |
children_list_items = li.children(o.listType).children('li') | |
var position = li.index(); | |
if (children_list_items.length > 0) { | |
children_list_items.each(function() { | |
_recursiveItems($(this)); | |
}); | |
} | |
var resource = li.attr("id").match(o.expression || (/(.+)[-=_](.+)/)); | |
var resourceName = o.key || resource[1]; | |
var serializedId = '[' + id +']'; | |
var container = resourceName + serializedId; | |
ret.push(container + '[parent_id]='+ parentId); | |
ret.push(container + '[position]='+ position); | |
//return item; | |
} | |
}, |
Author
ramontayag
commented
Jul 30, 2012
via email
Haha. That's great! Good to hear :)
Take care!
Ramon Tayag
On Mon, Jul 30, 2012 at 9:40 PM, mr-stateradio <
reply@reply.github.com
… wrote:
Beware, I might really come one day. ;-)
I like to travel to Asia. Have been already in Thailand and Bali. Its
really nice there :)
Anyway, when I really make it one day to Manila, I will drop you a line and
who knows.. maybe you really want your beer.
All the best and take care,
Thomas from Vienna!
On Mon, Jul 30, 2012 at 3:31 PM, Ramon Tayag <
***@***.***
> wrote:
>
> Haha :) When you come to the Philippines, sure!
> ---
>
> Reply to this email directly or view it on GitHub:
> https://gist.github.com/1013977
---
Reply to this email directly or view it on GitHub:
https://gist.github.com/1013977
Hello ramontayag,
sorry for being so late to this gist, but it so happens that I just stumbled upon your improvements and they really helped me.
Could you give me a hint on how to get the level of
My database asks for
~ item_id
~ parent_id
~ position
and
~ level (depth)
I don't know how to get this last one working.
There is a "_getLevel" function in the code, but I can't get it to work.
If you could help me with this, I would really appreciate.
Kind Regards,
Stefan
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment