[jQuery] Re: feature suggestion: .attr() without params returns the whole list of attributes

2009-01-06 Thread Balazs Endresz

Why not use $(el).data() for that?

On Jan 6, 12:57 pm, "Alexandre Plennevaux" 
wrote:
> I would like to suggest a feature to add to jquery attributes commands:
>
> I 'm using custom attributes to store UI states. At some point i would find
> it handy to be able to just console.log($(this).attr() ) to see all the
> attributes and their value.
>
> Not a groundbreaking change, but a nice -to-have...
>
> thanks
>
> Alexandre


[jQuery] Re: feature suggestion: .attr() without params returns the whole list of attributes

2009-01-06 Thread Ricardo Tomasi

You can't see all data saved either..

On Jan 6, 12:01 pm, Balazs Endresz  wrote:
> Why not use $(el).data() for that?
>
> On Jan 6, 12:57 pm, "Alexandre Plennevaux" 
> wrote:
>
> > I would like to suggest a feature to add to jquery attributes commands:
>
> > I 'm using custom attributes to store UI states. At some point i would find
> > it handy to be able to just console.log($(this).attr() ) to see all the
> > attributes and their value.
>
> > Not a groundbreaking change, but a nice -to-have...
>
> > thanks
>
> > Alexandre


[jQuery] Re: feature suggestion: .attr() without params returns the whole list of attributes

2009-01-06 Thread Balazs Endresz

You can, but it's undocumented and unnecessary :)

But you can have your own namespace:
$(el).data('myns.something', value);
so
$(el).data('myns'); will return all your properties.


On Jan 6, 5:06 pm, Ricardo Tomasi  wrote:
> You can't see all data saved either..
>
> On Jan 6, 12:01 pm, Balazs Endresz  wrote:
>
> > Why not use $(el).data() for that?
>
> > On Jan 6, 12:57 pm, "Alexandre Plennevaux" 
> > wrote:
>
> > > I would like to suggest a feature to add to jquery attributes commands:
>
> > > I 'm using custom attributes to store UI states. At some point i would 
> > > find
> > > it handy to be able to just console.log($(this).attr() ) to see all the
> > > attributes and their value.
>
> > > Not a groundbreaking change, but a nice -to-have...
>
> > > thanks
>
> > > Alexandre


[jQuery] Re: feature suggestion: .attr() without params returns the whole list of attributes

2009-01-06 Thread Richard D. Worth
.data() puts the namespace after the dot ( . ), not before. So it's

$(el).data('something.myns', value);

Event namespacing in jQuery is this way also

$(el).bind("click.foo", fn1)
$(el).bind("click.bar", fn2)
$(el).bind("click", fn3)
$(el).unbind(".foo")

- Richard

On Tue, Jan 6, 2009 at 11:58 AM, Balazs Endresz wrote:

>
> You can, but it's undocumented and unnecessary :)
>
> But you can have your own namespace:
> $(el).data('myns.something', value);
> so
> $(el).data('myns'); will return all your properties.
>
>
> On Jan 6, 5:06 pm, Ricardo Tomasi  wrote:
> > You can't see all data saved either..
> >
> > On Jan 6, 12:01 pm, Balazs Endresz  wrote:
> >
> > > Why not use $(el).data() for that?
> >
> > > On Jan 6, 12:57 pm, "Alexandre Plennevaux" 
> > > wrote:
> >
> > > > I would like to suggest a feature to add to jquery attributes
> commands:
> >
> > > > I 'm using custom attributes to store UI states. At some point i
> would find
> > > > it handy to be able to just console.log($(this).attr() ) to see all
> the
> > > > attributes and their value.
> >
> > > > Not a groundbreaking change, but a nice -to-have...
> >
> > > > thanks
> >
> > > > Alexandre
>


[jQuery] Re: feature suggestion: .attr() without params returns the whole list of attributes

2009-01-06 Thread Karl Swedberg
I just played around in Firebug and noticed that DOM elements have an  
"attributes" property (in Firefox, at least), so I tried this, using  
the first textarea in my document as an example:


var a = $('textarea')[0].attributes,
  attrs = [];
for (i=0; i < a.length; i++) {
  attrs.push(a[i].nodeName + ': ' + a[i].nodeValue);
}
attrs.join('\n');

and Firebug displayed all of the attributes, including expandos:

"id: other_qualifications
 name: other_qualifications
 class: optional
 rows: 3
 itsalltext_uid: 212w1e1b2r3d231z2g232q302c2x231i1e172v342v3b1p1p"

Not exactly what you wanted, but I still thought it was kind of cool/ 
worth sharing.


--Karl


Karl Swedberg
www.englishrules.com
www.learningjquery.com




On Jan 6, 2009, at 11:06 AM, Ricardo Tomasi wrote:



You can't see all data saved either..

On Jan 6, 12:01 pm, Balazs Endresz  wrote:

Why not use $(el).data() for that?

On Jan 6, 12:57 pm, "Alexandre Plennevaux" 
wrote:

I would like to suggest a feature to add to jquery attributes  
commands:


I 'm using custom attributes to store UI states. At some point i  
would find
it handy to be able to just console.log($(this).attr() ) to see  
all the

attributes and their value.



Not a groundbreaking change, but a nice -to-have...



thanks



Alexandre




[jQuery] Re: feature suggestion: .attr() without params returns the whole list of attributes

2009-01-06 Thread Alexandre Plennevaux

quite nice karl, thanx !

On Tue, Jan 6, 2009 at 6:09 PM, Karl Swedberg  wrote:
>
> I just played around in Firebug and noticed that DOM elements have an 
> "attributes" property (in Firefox, at least), so I tried this, using the 
> first textarea in my document as an example:
>
> var a = $('textarea')[0].attributes,
>   attrs = [];
> for (i=0; i < a.length; i++) {
>   attrs.push(a[i].nodeName + ': ' + a[i].nodeValue);
> }
> attrs.join('\n');
>
> and Firebug displayed all of the attributes, including expandos:
> "id: other_qualifications
>  name: other_qualifications
>  class: optional
>  rows: 3
>  itsalltext_uid: 212w1e1b2r3d231z2g232q302c2x231i1e172v342v3b1p1p"
>
> Not exactly what you wanted, but I still thought it was kind of cool/worth 
> sharing.
> --Karl
> 
> Karl Swedberg
> www.englishrules.com
> www.learningjquery.com
>
>
>
> On Jan 6, 2009, at 11:06 AM, Ricardo Tomasi wrote:
>
> You can't see all data saved either..
>
> On Jan 6, 12:01 pm, Balazs Endresz  wrote:
>
> Why not use $(el).data() for that?
>
> On Jan 6, 12:57 pm, "Alexandre Plennevaux" 
>
> wrote:
>
> I would like to suggest a feature to add to jquery attributes commands:
>
> I 'm using custom attributes to store UI states. At some point i would find
>
> it handy to be able to just console.log($(this).attr() ) to see all the
>
> attributes and their value.
>
> Not a groundbreaking change, but a nice -to-have...
>
> thanks
>
> Alexandre
>


[jQuery] Re: feature suggestion: .attr() without params returns the whole list of attributes

2009-01-06 Thread Joe

Balazs,

That throws an error in the data method.

Joe

On Jan 6, 10:06 am, Ricardo Tomasi  wrote:
> You can't see all data saved either..
>
> On Jan 6, 12:01 pm, Balazs Endresz  wrote:
>
> > Why not use $(el).data() for that?
>
> > On Jan 6, 12:57 pm, "Alexandre Plennevaux" 
> > wrote:
>
> > > I would like to suggest a feature to add to jquery attributes commands:
>
> > > I 'm using custom attributes to store UI states. At some point i would 
> > > find
> > > it handy to be able to just console.log($(this).attr() ) to see all the
> > > attributes and their value.
>
> > > Not a groundbreaking change, but a nice -to-have...
>
> > > thanks
>
> > > Alexandre


[jQuery] Re: feature suggestion: .attr() without params returns the whole list of attributes

2009-01-06 Thread Balazs Endresz

Hi Joe!

Sorry, I was wrong, as the namespace is reversed. But maybe using it
this way is easier and a bit faster:

$(el).data('myns', {});
var mydata=$(el).data('myns'); //save a reference
mydata.prop=0; //set
mydata.prop;  //get

Btw. if you're still working on it the translation plugin has gotten
modularized, so you can skip the the language detection and the "ready
event" is firing properly too :)

On Jan 6, 6:22 pm, Joe  wrote:
> Balazs,
>
> That throws an error in the data method.
>
> Joe
>
> On Jan 6, 10:06 am, Ricardo Tomasi  wrote:
>
> > You can't see all data saved either..
>
> > On Jan 6, 12:01 pm, Balazs Endresz  wrote:
>
> > > Why not use $(el).data() for that?
>
> > > On Jan 6, 12:57 pm, "Alexandre Plennevaux" 
> > > wrote:
>
> > > > I would like to suggest a feature to add to jquery attributes commands:
>
> > > > I 'm using custom attributes to store UI states. At some point i would 
> > > > find
> > > > it handy to be able to just console.log($(this).attr() ) to see all the
> > > > attributes and their value.
>
> > > > Not a groundbreaking change, but a nice -to-have...
>
> > > > thanks
>
> > > > Alexandre


[jQuery] Re: feature suggestion: .attr() without params returns the whole list of attributes

2009-01-07 Thread Joe

Oh nice!

Yeah what I need to do is get the source from you and add the cookie
settings to the plugin.  It's been working like a charm!

joe

On Jan 6, 11:45 am, Balazs Endresz  wrote:
> Hi Joe!
>
> Sorry, I was wrong, as the namespace is reversed. But maybe using it
> this way is easier and a bit faster:
>
> $(el).data('myns', {});
> var mydata=$(el).data('myns'); //save a reference
> mydata.prop=0; //set
> mydata.prop;  //get
>
> Btw. if you're still working on it the translation plugin has gotten
> modularized, so you can skip the the language detection and the "ready
> event" is firing properly too :)
>
> On Jan 6, 6:22 pm, Joe  wrote:
>
> > Balazs,
>
> > That throws an error in the data method.
>
> > Joe
>
> > On Jan 6, 10:06 am, Ricardo Tomasi  wrote:
>
> > > You can't see all data saved either..
>
> > > On Jan 6, 12:01 pm, Balazs Endresz  wrote:
>
> > > > Why not use $(el).data() for that?
>
> > > > On Jan 6, 12:57 pm, "Alexandre Plennevaux" 
> > > > wrote:
>
> > > > > I would like to suggest a feature to add to jquery attributes 
> > > > > commands:
>
> > > > > I 'm using custom attributes to store UI states. At some point i 
> > > > > would find
> > > > > it handy to be able to just console.log($(this).attr() ) to see all 
> > > > > the
> > > > > attributes and their value.
>
> > > > > Not a groundbreaking change, but a nice -to-have...
>
> > > > > thanks
>
> > > > > Alexandre