Skip to content

Commit 6179e0c

Browse files
rmurpheyscottgonzalez
authored andcommitted
First pass at fixing up references to $.fn methods. See #291.
1 parent 5619ee5 commit 6179e0c

19 files changed

+121
-113
lines changed

page/ajax/ajax-and-forms.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@ attribution:
99
jQuery's ajax capabilities can be especially useful when dealing with forms. There are several advantages, which can range from serialization, to simple client-side validation (e.g. "Sorry, that username is taken"), to [prefilters](http://api.jquery.com/extending-ajax/#Prefilters) (explained below), and even more!
1010

1111
### Serialization
12-
Serializing form inputs in jQuery is extremely easy. Two methods come supported natively — `$.fn.serialize` and `$.fn.serializeArray`. While the names are fairly self-explanatory, there are many advantages to using them.
1312

14-
The `serialize` method serializes a form's data into a query string. For the element's value to be serialized, it **must** have a `name` attribute. Please note that values from inputs with a type of `checkbox` or `radio` are included only if they are checked.
13+
Serializing form inputs in jQuery is extremely easy. Two methods come supported natively: `.serialize()` and `.serializeArray()`. While the names are fairly self-explanatory, there are many advantages to using them.
14+
15+
The `.serialize()` method serializes a form's data into a query string. For the element's value to be serialized, it **must** have a `name` attribute. Please note that values from inputs with a type of `checkbox` or `radio` are included only if they are checked.
1516

1617
```
1718
// Turning form data into a query string
@@ -21,7 +22,7 @@ $( "#myForm" ).serialize();
2122
// field_1=something&field2=somethingElse
2223
```
2324

24-
While plain old serialization is great, sometimes your application would work better if you sent over an array of objects, instead of just the query string. For that, jQuery has the `serializeArray` method. It's very similar to the `serialize` method listed above, except it produces an array of objects, instead of a string.
25+
While plain old serialization is great, sometimes your application would work better if you sent over an array of objects, instead of just the query string. For that, jQuery has the `.serializeArray()` method. It's very similar to the `.serialize()` method listed above, except it produces an array of objects, instead of a string.
2526

2627
```
2728
// Creating an array of objects containing form data

page/ajax/jquery-ajax-methods.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,19 @@ attribution:
66
- jQuery Fundamentals
77
---
88
While jQuery does offer many Ajax-related convenience methods, the core
9-
`$.ajax` method is at the heart of all of them, and understanding it is
9+
`$.ajax()` method is at the heart of all of them, and understanding it is
1010
imperative. We'll review it first, and then touch briefly on the convenience
1111
methods.
1212

13-
I generally use the `$.ajax` method and do not use convenience methods. As
13+
I generally use the `$.ajax()` method and do not use convenience methods. As
1414
you'll see, it offers features that the convenience methods do not, and its
1515
syntax is more easily understandable, in my opinion.
1616

17-
### `$.ajax`
17+
### `$.ajax()`
1818

19-
jQuery's core `$.ajax` method is a powerful and straightforward way of creating
19+
jQuerys core `$.ajax()` method is a powerful and straightforward way of creating
2020
Ajax requests. It takes a configuration object that contains all the
21-
instructions jQuery requires to complete the request. The `$.ajax` method is
21+
instructions jQuery requires to complete the request. The `$.ajax()` method is
2222
particularly valuable because it offers the ability to specify both success and
2323
failure callbacks. Also, its ability to take a configuration object that can
2424
be defined separately makes it easier to write reusable code. For complete
@@ -27,7 +27,7 @@ documentation of the configuration options, visit
2727
documentation on api.jquery.com").
2828

2929
```
30-
// Using the core $.ajax method
30+
// Using the core $.ajax() method
3131
$.ajax({
3232
// the URL for the request
3333
url: "post.php",
@@ -71,9 +71,9 @@ you're asking for, and verify that the `Content-type` header is accurate for the
7171
data type. For example, for JSON data, the `Content-type` header should be
7272
`application/json`.
7373

74-
### `$.ajax` Options
74+
### `$.ajax()` Options
7575

76-
There are many, many options for the `$.ajax` method, which is part of its
76+
There are many, many options for the `$.ajax()` method, which is part of its
7777
power. For a complete list of options, visit
7878
[http://api.jquery.com/jQuery.ajax/](http://api.jquery.com/jQuery.ajax/ "$.ajax
7979
documentation on api.jquery.com"); here are several that you will use
@@ -101,7 +101,7 @@ the request.
101101

102102
The scope in which the callback function(s) should run (i.e. what `this` will
103103
mean inside the callback function(s)). By default, `this` inside the callback
104-
function(s) refers to the object originally passed to `$.ajax`.
104+
function(s) refers to the object originally passed to `$.ajax()`.
105105

106106
#### data
107107

@@ -150,17 +150,17 @@ all browsers.
150150

151151
The URL for the request.
152152

153-
The `url` option is the only required property of the `$.ajax` configuration
153+
The `url` option is the only required property of the `$.ajax()` configuration
154154
object; all other properties are optional. This can also be passed as the first
155-
argument to `$.ajax`, and the options object as the second argument.
155+
argument to `$.ajax()`, and the options object as the second argument.
156156

157157
### Convenience Methods
158158

159-
If you don't need the extensive configurability of `$.ajax`, and you don't care
159+
If you don't need the extensive configurability of `$.ajax()`, and you don't care
160160
about handling errors, the Ajax convenience functions provided by jQuery can be
161161
useful, terse ways to accomplish Ajax requests. These methods are just
162-
"wrappers" around the core `$.ajax` method, and simply pre-set some of the
163-
options on the `$.ajax` method.
162+
"wrappers" around the core `$.ajax()` method, and simply pre-set some of the
163+
options on the `$.ajax()` method.
164164

165165
The convenience methods provided by jQuery are:
166166

@@ -233,8 +233,8 @@ $.getJSON( "/details.php", function( resp ) {
233233

234234
### `$.fn.load`
235235

236-
The `$.fn.load` method is unique among jQuery's Ajax methods in that it is
237-
called on a selection. The `$.fn.load` method fetches HTML from a URL, and
236+
The `.load()` method is unique among jQuerys Ajax methods in that it is
237+
called on a selection. The `.load()` method fetches HTML from a URL, and
238238
uses the returned HTML to populate the selected element(s). In addition to
239239
providing a URL to the method, you can optionally provide a selector; jQuery
240240
will fetch only the matching content from the returned HTML.

page/effects/custom-effects.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
---
2-
title : Custom Effects with $.fn.animate
2+
title : Custom Effects with .animate()
33
level: beginner
44
source: http://jqfundamentals.com/legacy
55
attribution:
66
- jQuery Fundamentals
77
---
88
jQuery makes it possible to animate arbitrary CSS properties via the
9-
`$.fn.animate` method. The `$.fn.animate` method lets you animate to a set
9+
`.animate()` method. The `.animate()` method lets you animate to a set
1010
value, or to a value relative to the current value.
1111

1212
```
13-
// Custom effects with $.fn.animate
13+
// Custom effects with .animate()
1414
$( "div.funtimes" ).animate({
1515
left: "+=50",
1616
opacity: 0.25
@@ -22,7 +22,7 @@ $( "div.funtimes" ).animate({
2222
});
2323
```
2424

25-
**Note:** Color-related properties cannot be animated with `$.fn.animate` using jQuery
25+
**Note:** Color-related properties cannot be animated with `.animate()` using jQuery
2626
out of the box. Color animations can easily be accomplished by including the
2727
[color plugin](http://github.com/jquery/jquery-color). We'll discuss using
2828
plugins later in the book.
@@ -35,7 +35,7 @@ jQuery includes only two methods of easing: swing and linear. If you want more
3535
natural transitions in your animations, various easing plugins are available.
3636

3737
As of jQuery 1.4, it is possible to do per-property easing when using the
38-
`$.fn.animate` method.
38+
`.animate()` method.
3939

4040
```
4141
// Per-property easing

page/effects/intro-to-effects.md

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ level: beginner
55

66
## Showing and Hiding Content
77

8-
jQuery can show or hide content instantaneously with `$.fn.show` or `$.fn.hide`:
8+
jQuery can show or hide content instantaneously with `.show()` or `.hide()`:
99

1010
```
1111
// Instantaneously hide all paragraphs
@@ -19,8 +19,8 @@ When jQuery hides an element, it sets its CSS `display` property to `none`. This
1919
zero width and height; it does not mean that the content will simply become transparent and leave an empty area on the page.
2020

2121
jQuery can also show or hide content by means of animation effects. You can tell
22-
`$.fn.show` and `$.fn.hide` to use animation in a couple of ways. One is to pass
23-
in a string-valued argument of `slow`, `normal`, or `fast`:
22+
`.show()` and `.hide()` to use animation in a couple of ways. One is to pass
23+
in an argument of `'slow'`, `'normal'`, or `'fast'`:
2424

2525
```
2626
// Slowly hide all paragraphs
@@ -31,7 +31,7 @@ $( "div.hidden" ).show( "fast" );
3131
```
3232

3333
If you prefer more direct control over the duration of the animation effect, you
34-
can pass the desired duration in milliseconds to `$.fn.show` and `$.fn.hide`:
34+
can pass the desired duration in milliseconds to `.show()` and `.hide()`:
3535

3636
```
3737
// Hide all paragraphs over half a second
@@ -46,9 +46,9 @@ over the duration.
4646

4747
##Fade and Slide Animations
4848

49-
You may have noticed that `$.fn.show` and `$.fn.hide` use a combination of slide and fade effects
49+
You may have noticed that `.show()` and `.hide()` use a combination of slide and fade effects
5050
when showing and hiding content in an animated way. If you would rather show or hide content with
51-
one effect or the other, there are additional methods that can help. `$.fn.slideDown` and `$.fn.slideUp`
51+
one effect or the other, there are additional methods that can help. `.slideDown()` and `.slideUp()`
5252
show and hide content, respectively, using only a slide effect. Slide animations are accomplished by
5353
rapidly making changes to an element's CSS `height` property.
5454

@@ -60,7 +60,7 @@ $( "p" ).slideUp( 800 );
6060
$( "div.hidden" ).slideDown( 600 );
6161
```
6262

63-
Similarly `$.fn.fadeIn` and `$.fn.fadeOut` show and hide content, respectively, by means of a fade
63+
Similarly `.fadeIn()` and `.fadeOut()` show and hide content, respectively, by means of a fade
6464
animation. Fade animations involve rapidly making changes to an element's CSS `opacity` property.
6565

6666
```
@@ -73,9 +73,9 @@ $( "div.hidden" ).fadeIn( 750 );
7373

7474
##Changing Display Based on Current Visibility State
7575

76-
jQuery can also let you change a content's visibility based on its current visibility state. `$.fn.toggle`
76+
jQuery can also let you change a content's visibility based on its current visibility state. `.toggle()`
7777
will show content that is currently hidden and hide content that is currently visible. You can pass the
78-
same arguments to `$.fn.toggle` as you pass to any of the effects methods above.
78+
same arguments to `.toggle()` as you pass to any of the effects methods above.
7979

8080
```
8181
// Instantaneously toggle the display of all paragraphs
@@ -88,8 +88,8 @@ $( "img" ).toggle( "slow" );
8888
$( "div" ).toggle( 1800 );
8989
```
9090

91-
`$.fn.toggle` will use a combination of slide and fade effects, just as `$.fn.show` and `$.fn.hide` do. You can
92-
toggle the display of content with just a slide or a fade using `$.fn.slideToggle` and `$.fn.fadeToggle`.
91+
`.toggle()` will use a combination of slide and fade effects, just as `.show()` and `.hide()` do. You can
92+
toggle the display of content with just a slide or a fade using `.slideToggle()` and `.fadeToggle()`.
9393

9494
```
9595
// Toggle the display of all ordered lists over 1 second using slide up/down animations
@@ -109,10 +109,10 @@ chain will wait until the animation runs to completion.
109109
$( "p.hidden" ).fadeIn( 750 ).addClass( "lookAtMe" );
110110
```
111111

112-
It is important to realize that `$.fn.fadeIn` above only *kicks off* the animation. Once started, the
112+
It is important to realize that `.fadeIn()` above only *kicks off* the animation. Once started, the
113113
animation is implemented by rapidly changing CSS properties in a JavaScript `setInterval()` loop. When
114-
you call `$.fn.fadeIn`, it starts the animation loop and then returns the jQuery object, passing it along
115-
to `$.fn.addClass` which will then add the `lookAtMe` style class while the animation loop is just
114+
you call `.fadeIn()`, it starts the animation loop and then returns the jQuery object, passing it along
115+
to `.addClass()` which will then add the `lookAtMe` style class while the animation loop is just
116116
getting started.
117117

118118
To defer an action until after an animation has run to completion, you need to use an animation callback
@@ -151,9 +151,9 @@ if ( $someElement.length ) {
151151

152152
jQuery provides some additional features for controlling your animations:
153153

154-
### `$.fn.stop`
154+
### `.stop()`
155155

156-
`$.fn.stop` will immediately terminate all animations running on the elements in your selection. You might give
156+
`.stop()` will immediately terminate all animations running on the elements in your selection. You might give
157157
end-users control over page animations by rigging a button they can click to stop the animations.
158158

159159
```
@@ -166,9 +166,9 @@ $( "input" ).attr({
166166
}).appendTo( document.body );
167167
```
168168

169-
### `$.fn.delay`
169+
### `.delay()`
170170

171-
`$.fn.delay` is used to introduce a delay between successive animations. For example:
171+
`.delay()` is used to introduce a delay between successive animations. For example:
172172

173173
```
174174
// Hide all level 1 headings over half a second; then wait for 1.5 seconds

page/events/event-basics.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ In some cases, such as the page load and unload events, the browser itself will
1616
trigger the event.
1717

1818
jQuery offers convenience methods for most native browser events. These methods —
19-
including `$.fn.click`, `$.fn.focus`, `$.fn.blur`, `$.fn.change`, etc. — are shorthand
20-
for jQuery's `$.fn.on` method. The `on` method is useful for binding the same handler
19+
including `.click()`, `.focus()`, `.blur()`, `.change()`, etc. — are shorthand
20+
for jQuery's `.on()` method. The on method is useful for binding the same handler
2121
function to multiple events, when you want to provide data to the event hander,
2222
when you are working with custom events, or when you want to pass an object of
2323
multiple events and handlers.
@@ -30,15 +30,15 @@ $( "p" ).click(function() {
3030
```
3131

3232
```
33-
// Equivalent event setup using the `$.fn.on` method
33+
// Equivalent event setup using the `.on()` method
3434
$( "p" ).on( "click", function() {
3535
console.log( "click" );
3636
});
3737
```
3838

3939
### Extending Events to New Page Elements
4040

41-
It is important to note that `$.fn.on` can only create event listeners
41+
It is important to note that `.on()` can only create event listeners
4242
on elements that exist *at the time you set up the listeners*. Similar elements created
4343
after the event listeners are established will not automatically pick up event behaviors
4444
you've set up previously. For example:
@@ -57,7 +57,7 @@ $( document ).ready(function(){
5757
});
5858
```
5959

60-
Consult the article on event delegation to see how to use `$.fn.on` so that
60+
Consult the article on event delegation to see how to use `.on()` so that
6161
event behaviors will be extended to new elements without having to rebind them.
6262

6363
### Inside the Event Handler Function
@@ -85,7 +85,7 @@ The button or key that was pressed.
8585
Any data that was passed in when the event was bound. For example:
8686

8787
```
88-
// Event setup using the `$.fn.on` method with data
88+
// Event setup using the `.on()` method with data
8989
$( "input" ).on(
9090
"change",
9191
{ foo: "bar" }, // associate data with event binding
@@ -141,7 +141,7 @@ $( "a" ).click(function( eventObject ) {
141141

142142
Quite often elements in your application will be bound to multiple events. If
143143
multiple events are to share the same handling function, you can provide the event types
144-
as a space-separated list to `$.fn.on`:
144+
as a space-separated list to `.on()`:
145145

146146
```
147147
// Multiple events, same handler
@@ -153,7 +153,7 @@ $( "input" ).on(
153153
);
154154
```
155155

156-
When each event has its own handler, you can pass an object into `$.fn.on` with one or
156+
When each event has its own handler, you can pass an object into `.on()` with one or
157157
more key/value pairs, with the key being the event name and the value being the function
158158
to handle the event.
159159

@@ -180,7 +180,7 @@ $( "p" ).off( ".myNamespace" ); // unbind all events in the namespace
180180

181181
### Tearing Down Event Listeners
182182

183-
To remove an event listener, you use the `$.fn.off` method and pass in
183+
To remove an event listener, you use the `.off()` method and pass in
184184
the event type to off. If you attached a named function to the event, then
185185
you can isolate the event tear down to just that named function by passing it as the
186186
second argument.
@@ -203,7 +203,7 @@ $( "p" ).off( "click", bar ); // foo is still bound to the click event
203203

204204
Sometimes you need a particular handler to run only once — after that, you may
205205
want no handler to run, or you may want a different handler to run. jQuery
206-
provides the `$.fn.one` method for this purpose.
206+
provides the `.one()` method for this purpose.
207207

208208
```
209209
// Switching handlers using the `$.fn.one` method
@@ -221,10 +221,10 @@ Note that in the code snippet above, the `firstClick` function will be executed
221221
the first click on *each* paragraph element rather than the function being removed from
222222
*all* paragraphs when *any* paragraph is clicked for the first time.
223223

224-
`$.fn.one` can also be used to bind multiple events:
224+
`.one()` can also be used to bind multiple events:
225225

226226
```
227-
// Using $.fn.one to bind several events
227+
// Using .one() to bind several events
228228
$( "input[id]" ).one( "focus mouseover keydown", firstEvent);
229229
230230
function firstEvent( eventObject ) {

page/events/event-helpers.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@ attribution:
77
---
88
jQuery offers two event-related helper functions that save you a few keystrokes.
99

10-
### `$.fn.hover`
10+
### `.hover()`
1111

12-
The `$.fn.hover` method lets you pass one or two functions to be run when the
12+
The `.hover()` method lets you pass one or two functions to be run when the
1313
`mouseenter` and `mouseleave` events occur on an element. If you pass one
1414
function, it will be run for both events; if you pass two functions, the first
1515
will run for `mouseenter`, and the second will run for `mouseleave`.
1616

17-
**Note:** Prior to jQuery 1.4, the `$.fn.hover` method required two functions.
17+
**Note:** Prior to jQuery 1.4, the `.hover()` method required two functions.
1818

1919
```
2020
// The hover helper function
@@ -23,11 +23,11 @@ $( "#menu li" ).hover(function() {
2323
});
2424
```
2525

26-
### `$.fn.toggle`
26+
### `.toggle()`
2727

28-
The `$.fn.toggle` method is triggered by the "click" event and accepts two or
28+
The `.toggle()` method is triggered by the "click" event and accepts two or
2929
more functions. Each time the click event occurs, the next function in the
30-
list is called. Generally, `$.fn.toggle` is used with just two functions;
30+
list is called. Generally, `.toggle()` is used with just two functions;
3131
however, it will accept an unlimited number of functions. Be careful, though:
3232
providing a long list of functions can be difficult to debug.
3333

0 commit comments

Comments
 (0)