Skip to content

Decide on one consistent way of referring to functions #291

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
alimony opened this issue Mar 3, 2013 · 12 comments
Closed

Decide on one consistent way of referring to functions #291

alimony opened this issue Mar 3, 2013 · 12 comments

Comments

@alimony
Copy link

alimony commented Mar 3, 2013

The various pages currently use:

  • jQuery.functionName()
  • jQuery.fn.functionName()
  • $.functionName()
  • $.fn.functionName()
  • .functionName()
  • functionName()
  • .functionName
  • functionName

There should be an easy rule for the format when mentioning functions in body text (i.e. outside code blocks) and all pages should conform to that rule. Should probably go into the style guidelines as well.

@rdworth
Copy link
Contributor

rdworth commented Mar 3, 2013

We have a couple rules already in http://learn.jquery.com/style-guide/ in the Code within Prose section. Most of the examples you mention are covered by them. The rules may inform whether some inconsistency currently exists. There may also be a missing guideline, but we should start with what we have and see what isn't sufficiently covered by it. Specific examples would help.

@alimony
Copy link
Author

alimony commented Mar 3, 2013

Yes, I must have glossed over that part a bit too quickly… the only part that is not covered, I guess, is whether to use jQuery or $ for the jQuery object. And whether to always include .fn. if it's a method in jQuery's prototype.

@rdworth
Copy link
Contributor

rdworth commented Mar 3, 2013

The last guideline in that list covers method on the jQuery prototype. Always simply .functionName() An exception would be if it was instruction about how it is stored on the prototype, what it's called and what that looks like.

I'll let @ajpiano and/or @kswedberg weight in on jQuery vs. $

@alimony
Copy link
Author

alimony commented Mar 3, 2013

@rdworth Would that mean that all occurrences of $.fn.functionName() should be changed to $.functionName()?

@rmurphey
Copy link
Contributor

rmurphey commented Mar 3, 2013

@alimony $.fn.functionName() and $.functionName() are two different things, so no :)

My understanding is as follows:

  • When referring to a method that is on the jQuery prototype, such as .html(), then it should be referred to as I just did there, leaving off the $.fn part. The only time to include $.fn is when specifically discussing the jQuery prototype (which is aliased as $.fn).
  • When referring to methods that are not on the jQuery prototype -- such as $.inArray() -- they should be referred to using their full name: $.inArray().

@rdworth
Copy link
Contributor

rdworth commented Mar 3, 2013

@rmurphey has it right. Sorry I forgot to clarify the diff between $.fn. methods and $. methods

@alimony
Copy link
Author

alimony commented Mar 3, 2013

@rmurphey @rdworth Thanks for the clarification! Then there's a whole lot of $.fn.functionName()'s that need to be shortened throughout the pages :)

@alimony
Copy link
Author

alimony commented Mar 3, 2013

Feel free to close this issue; @rmurphey's clear points may or may not have a place in the style guidelines, but that is not for me to decide.

@kswedberg
Copy link
Member

👍 to @rmurphey's points/clarification. That's the way we refer to things in the API documentation, at least. Unless @ajpiano objects, we should probably update the learn.jquery.com style guide to cover methods of the jQuery object such as $.inArray() and to suggest use of $ over jQuery with the usual exceptions ( jQuery.noConflict(), passing jQuery to an IIFE, etc.).

@rmurphey
Copy link
Contributor

rmurphey commented Mar 3, 2013

I will have a pull request shortly that cleans up the current content where $.fn is used.

@ajpiano
Copy link
Member

ajpiano commented Mar 4, 2013

+1 to @rmurphey's suggestion as well. We should amend the style guide and then we can close this issue

@scottgonzalez
Copy link
Member

This is already documented on http://learn.jquery.com/style-guide/#code-within-prose

arthurvr pushed a commit to arthurvr/learn.jquery.com that referenced this issue Jan 4, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

6 participants