[jQuery] Re: data cache and tag attributes
I explored this in a little more detail (specifically, adding non standard attributes to HTML markup), and wrote up my thoughts. http://pa.ulcarey.com/articles/2008/09/04/illegally-embedding-attributes-for-fun-and-profit On Sep 2, 8:33 am, Paul Carey [EMAIL PROTECTED] wrote: Very helpful, thanks for the response. Paul On Aug 28, 12:16 pm, Richard D. Worth [EMAIL PROTECTED] wrote: Some downsides to using expandos (arbitrary attribute key/value pairs on DOMElements): 1) possible memory leaks 2) keyname choice is limited because of built in attributes/properties 3) have to be careful about what you stick in there (see 1). Best to stick with simple values, ints and strings jQuery solves these by putting at most 1expandoon each element. The value is an int, so it's safe from memory leaks. The attribute key is prefixed with 'jquery' so there's no naming collision. Then the object store/cacheis completely external to the DOMElement itself. It's as easy to use as .attr(); just substitute .data(). - Richard
[jQuery] Re: data cache and tag attributes
Very helpful, thanks for the response. Paul On Aug 28, 12:16 pm, Richard D. Worth [EMAIL PROTECTED] wrote: Some downsides to using expandos (arbitrary attribute key/value pairs on DOMElements): 1) possible memory leaks 2) keyname choice is limited because of built in attributes/properties 3) have to be careful about what you stick in there (see 1). Best to stick with simple values, ints and strings jQuery solves these by putting at most 1 expando on each element. The value is an int, so it's safe from memory leaks. The attribute key is prefixed with 'jquery' so there's no naming collision. Then the object store/cache is completely external to the DOMElement itself. It's as easy to use as .attr(); just substitute .data(). - Richard
[jQuery] Re: callback executed before effect ended
problem is that next element appears while current element is still fading out, any idea what i'm doing wrong? Maybe you could add display:none; to the current css class. Paul
[jQuery] data cache and tag attributes
Hi I've been setting arbitrary attributes on my html tags, and using jQuery to make AJAX requests based on their values. These has worked well so far as writing out arbitrary attributes from the backend is trivial. But I'm about to start using per element attributes more intensively, and now I'm questioning my approach. I'm aware that jQuery UI makes heavy use of the data cache and I assume it does so with good reason. At what point does it make more sense to use the data cache rather than just set html attributes? I'm thinking when closures or rich JavaScript objects are required? If my needs are met by key / value pairs are there any downsides to arbitrary attributes that I should be aware of? Many thanks Paul