[jQuery] Re: Not a plugin but code for anyone trying to have collapse-able menu with cookies

2008-01-31 Thread Charles K. Clarkson
Karl Swedberg wrote: : On my test page (http://test.learningjquery.com/cookie-menu.html), I : put a link to another page with the same script and menu so you can : see the persistence of the expand/collapse state. Never being able to leave well enough alone and having a little time on my

[jQuery] Re: Not a plugin but code for anyone trying to have collapse-able menu with cookies

2008-01-31 Thread Karl Swedberg
Very cool, Charles! Wow, I wish I had the time to study all the stuff that comes through this discussion list. Hard to keep up. --Karl _ Karl Swedberg www.englishrules.com www.learningjquery.com On Jan 31, 2008, at 8:22 AM, Charles K. Clarkson wrote: Karl Swedberg

[jQuery] Re: Not a plugin but code for anyone trying to have collapse-able menu with cookies

2008-01-30 Thread Karl Swedberg
that's awesome, Jörn! Thanks for sharing that code. I'm looking forward to playing around with it. Cheers, --Karl _ Karl Swedberg www.englishrules.com www.learningjquery.com On Jan 29, 2008, at 6:49 PM, Jörn Zaefferer wrote: Karl Swedberg schrieb: Sorry for the

[jQuery] Re: Not a plugin but code for anyone trying to have collapse-able menu with cookies

2008-01-30 Thread Bhaarat Sharma
Hi ty, If I understand your question correctly..I think you mean that if this menu was used throughout the site and your pages would be doing an include on this js file, will the menu stay the same from page to page with user selections. The answer is yes (i think), because it is using cookies.

[jQuery] Re: Not a plugin but code for anyone trying to have collapse-able menu with cookies

2008-01-30 Thread Karl Swedberg
On Jan 30, 2008, at 10:57 AM, Bhaarat Sharma wrote: Hi ty, If I understand your question correctly..I think you mean that if this menu was used throughout the site and your pages would be doing an include on this js file, will the menu stay the same from page to page with user selections. The

[jQuery] Re: Not a plugin but code for anyone trying to have collapse-able menu with cookies

2008-01-29 Thread Karl Swedberg
Hi Bhaarat, You've done a nice job here! I was wondering, though, if we could take advantage of the index value of the links, so I re-factored your code a bit (still using Klaus's cookie plugin). Here is what it looks like: $(document).ready(function() { $('#menu li ul').hide(); var

[jQuery] Re: Not a plugin but code for anyone trying to have collapse-able menu with cookies

2008-01-29 Thread Karl Swedberg
No problem, Bhaarat! Glad you like it. Actually, the way I set it up, mine was limited to 10 or fewer links. But we can increase that number by calling a function that returns, for example, a base-32 string instead of index: function bigIndex(inival) { return (inival).toString(32); }

[jQuery] Re: Not a plugin but code for anyone trying to have collapse-able menu with cookies

2008-01-29 Thread ocyrus
I always solved this problem with a database table, but this is solution when no database is being used. Nice. On Jan 29, 10:41 am, Bhaarat Sharma [EMAIL PROTECTED] wrote: Hi, I took the code from jQuery Accordion menu and am using the cookie plugin. while searching for a collapse-able

[jQuery] Re: Not a plugin but code for anyone trying to have collapse-able menu with cookies

2008-01-29 Thread Bhaarat Sharma
Hi Karl, Thanks a lot! your solution is obviously much better and not dependent on how many links there are. since you are using 'each' function. I had the concept with me but not the power of ins and outs of jQuery :) Next i'll be trying to make

[jQuery] Re: Not a plugin but code for anyone trying to have collapse-able menu with cookies

2008-01-29 Thread Karl Swedberg
Sorry for the repeat posts, but this is the first time I've looked at this sort of thing. I just realized that we can get up to 100 items by changing that bigIndex function -- just pad values less than 10 and append a delimiter to each one: function bigIndex(inival) { return inival

[jQuery] Re: Not a plugin but code for anyone trying to have collapse-able menu with cookies

2008-01-29 Thread Jörn Zaefferer
Karl Swedberg schrieb: Sorry for the repeat posts, but this is the first time I've looked at this sort of thing. I just realized that we can get up to 100 items by changing that bigIndex function -- just pad values less than 10 and append a delimiter to each one: [...] The serialization

[jQuery] Re: Not a plugin but code for anyone trying to have collapse-able menu with cookies

2008-01-29 Thread Richard D. Worth
You could take it a step further and encode that binary (string of 1s and 0s) as a decimal, and store that. Cool. function b2d(b) { return parseInt(b, 2); } function d2b(d) { return d.toString(2); } - Richard On Jan 29, 2008 6:49 PM, Jörn Zaefferer [EMAIL PROTECTED] wrote: Karl Swedberg