On Mon, Jan 17, 2011 at 11:52 PM, Miller Medeiros <[email protected]> wrote: > since in your case it seems to be just one, I would just store a single > cookie with the name of the setting and since you are already using jQuery > search for a cookie plugin, it may help you with the expires and retrieving > the proper data.. or you could just use: `document.cookie = > 'myAwesomeSetting=lorem';` > > if you have a bunch of checkboxes maybe it's better to store on a cookie a > number that represents all of them: > http://blog.millermedeiros.com/2010/12/using-integers-to-store-multiple-boolean-values/ > - depending on how many you have it may be easier to check which ones are > checked and respond to it that way.. > > $('#my-check-box').attr('checked', true); -> should work cross browser if > it is a checkbox. > > and you can check if a checkbox is checked by using > `$('#my-check-box').is(':checked')`... >
these two $() statements alone deserve a long chapter by themselves to exactly explain all the inconsistencies that may arise by using them together (probably even for checkboxes). There is also a problem with mixing strings and booleans to consider in your example (or in jQuery anyway). Comparing values obtained by direct DOM properties access (pseudo-selector) with values obtained by accessing HTML attributes through getter/setter in that way is scary at best (maybe worth a digest in JSMentors). -- Diego > Garret comment about doing on the server-side may be the best approach in > some cases (it all depends on how is the structure of what you are doing). > > PS: maybe the jQuery list should be a better place for this kind of question > since it is more specific and probably there is more people with the same > kind of questions or maybe someone even answered it before.. (don't know > what the moderators think about that..) > > cheers. > > -- > To view archived discussions from the original JSMentors Mailman list: > http://www.mail-archive.com/[email protected]/ > > To search via a non-Google archive, visit here: > http://www.mail-archive.com/[email protected]/ > > To unsubscribe from this group, send email to > [email protected] > -- To view archived discussions from the original JSMentors Mailman list: http://www.mail-archive.com/[email protected]/ To search via a non-Google archive, visit here: http://www.mail-archive.com/[email protected]/ To unsubscribe from this group, send email to [email protected]
