Re: [jQuery] Documentation of return objects?
> I think what he's talking about is whether or not it returns what was > just added to the document or the original element. Another example > would be whether or not .clone() return the cloned elements in the > jQuery set or the original elements. Those sorts of things aren't > listed. Good point, and sometimes I have to pause when using a method I haven't used before. However, I think most jQuery methods fall into just three categories. (I use $ to mean "the elements currently selected by this jQuery object.") 1) Standard methods -- most not listed below Do not change $ and return $ for chaining. If the method creates nodes, they are not part of $. If the method removes nodes that are part of $, the references in $ remain. (That is, they have been removed from the document but are still in $ so you could put them back using a method like appendTo further down the chain.) 2) Filtering methods -- filter, add, not, parents, etc. Push $ on an internal stack and return the (new) filtered $ for chaining. The original $ is available by using .end() in the chain to pop the stack. 3) Set/Get methods -- height, width, css, etc. Called with N arguments (usually none), return the value of the property for the *first* node (element 0) in the jQuery object. Called with N+1 arguments, set the value of the property for each node in $ using the final argument. Return the unchanged $ for chaining. Can anyone think of exceptions? Perhaps the doc could define (Standard, Filtering, SetGet) and we can just document the types of return-value behavior using those terms. ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] Documentation of return objects?
Visual jQuery is actually fairly identical to the API. It's an oversight that I don't have the return classes. I will add that tonight :-D-- YehudaOn 10/11/06, Kurt Mackey <[EMAIL PROTECTED]> wrote:Heh, and to think I've been using Visual jQuery all this time. Anyway, that link's a start, but it doesn't help clarify what .afterreturns, for instance.Maybe I should go through and write all these up.-Original Message-From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] OnBehalf Of John ResigSent: Wednesday, October 11, 2006 12:11 PMTo: jQuery Discussion.Subject: Re: [jQuery] Documentation of return objects? Yep:http://jquery.com/api/On 10/11/06, Kurt Mackey <[EMAIL PROTECTED]> wrote:> Are the return types for various methods documented anywhere? I can > guess on most of them, but I'd like a handy cheat sheet showing that> .html('blah') returns the original element.>> Things like .after() aren't at all obvious, however, and I could see a> reasonable case for it to either return the original element, or the > inserted element.___jQuery mailing listdiscuss@jquery.comhttp://jquery.com/discuss/ ___jQuery mailing listdiscuss@jquery.comhttp://jquery.com/discuss/ -- Yehuda KatzWeb Developer | Wycats Designs(ph) 718.877.1325 ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] Documentation of return objects?
And if I recall correctly, .after() and its ilk return the original element if only for the logistical difficulty of determining what part of the (not necessarily single element wrapped. for example $('p').after(''); is the p.first in the jQuery set or is p.last in the jQuery set?) new elements to assign to the jQuery set. And .clone() returns the cloned elements but you can return to the original set through the wonders of .end() -blair Kurt Mackey wrote: > Yep, that's correct, even if I can't write very clearly. ;) > > > -Original Message- > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On > Behalf Of Blair Mitchelmore > Sent: Wednesday, October 11, 2006 1:07 PM > To: jQuery Discussion. > Subject: Re: [jQuery] Documentation of return objects? > > I think what he's talking about is whether or not it returns what was > just added to the document or the original element. Another example > would be whether or not .clone() return the cloned elements in the > jQuery set or the original elements. Those sorts of things aren't listed > > in the documentation. > > -blair > > John Resig wrote: >>> Anyway, that link's a start, but it doesn't help clarify what .after >>> returns, for instance. >> According to that link, .after() always returns a jQuery object. While >> .html() can return either a jQuery object or a String, depending on >> the arguments passed in. >> >> If something returns a jQuery object, that means that its chainable >> and that you can continue to add actions on to it (e.g. >> $().after().html("foo").after()...) >> >> --John > ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] Documentation of return objects?
Yep, that's correct, even if I can't write very clearly. ;) -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Blair Mitchelmore Sent: Wednesday, October 11, 2006 1:07 PM To: jQuery Discussion. Subject: Re: [jQuery] Documentation of return objects? I think what he's talking about is whether or not it returns what was just added to the document or the original element. Another example would be whether or not .clone() return the cloned elements in the jQuery set or the original elements. Those sorts of things aren't listed in the documentation. -blair John Resig wrote: >> Anyway, that link's a start, but it doesn't help clarify what .after >> returns, for instance. > According to that link, .after() always returns a jQuery object. While > .html() can return either a jQuery object or a String, depending on > the arguments passed in. > > If something returns a jQuery object, that means that its chainable > and that you can continue to add actions on to it (e.g. > $().after().html("foo").after()...) > > --John ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/ ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] Documentation of return objects?
I think what he's talking about is whether or not it returns what was just added to the document or the original element. Another example would be whether or not .clone() return the cloned elements in the jQuery set or the original elements. Those sorts of things aren't listed in the documentation. -blair John Resig wrote: >> Anyway, that link's a start, but it doesn't help clarify what .after >> returns, for instance. > According to that link, .after() always returns a jQuery object. While > .html() can return either a jQuery object or a String, depending on > the arguments passed in. > > If something returns a jQuery object, that means that its chainable > and that you can continue to add actions on to it (e.g. > $().after().html("foo").after()...) > > --John ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] Documentation of return objects?
> Anyway, that link's a start, but it doesn't help clarify what .after > returns, for instance. According to that link, .after() always returns a jQuery object. While .html() can return either a jQuery object or a String, depending on the arguments passed in. If something returns a jQuery object, that means that its chainable and that you can continue to add actions on to it (e.g. $().after().html("foo").after()...) --John ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] Documentation of return objects?
Heh, and to think I've been using Visual jQuery all this time. Anyway, that link's a start, but it doesn't help clarify what .after returns, for instance. Maybe I should go through and write all these up. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of John Resig Sent: Wednesday, October 11, 2006 12:11 PM To: jQuery Discussion. Subject: Re: [jQuery] Documentation of return objects? Yep: http://jquery.com/api/ On 10/11/06, Kurt Mackey <[EMAIL PROTECTED]> wrote: > Are the return types for various methods documented anywhere? I can > guess on most of them, but I'd like a handy cheat sheet showing that > .html('blah') returns the original element. > > Things like .after() aren't at all obvious, however, and I could see a > reasonable case for it to either return the original element, or the > inserted element. ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/ ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] Documentation of return objects?
Yep: http://jquery.com/api/ On 10/11/06, Kurt Mackey <[EMAIL PROTECTED]> wrote: > Are the return types for various methods documented anywhere? I can > guess on most of them, but I'd like a handy cheat sheet showing that > .html('blah') returns the original element. > > Things like .after() aren't at all obvious, however, and I could see a > reasonable case for it to either return the original element, or the > inserted element. ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
[jQuery] Documentation of return objects?
Are the return types for various methods documented anywhere? I can guess on most of them, but I'd like a handy cheat sheet showing that .html('blah') returns the original element. Things like .after() aren't at all obvious, however, and I could see a reasonable case for it to either return the original element, or the inserted element. ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/