Skip to content

Commit bb154e5

Browse files
Markus Amalthea Magnusonajpiano
Markus Amalthea Magnuson
authored andcommitted
Style and typography fixes, and code style adherence in the Code Organization section. Fixes jquery#287.
1 parent 886780b commit bb154e5

File tree

7 files changed

+416
-468
lines changed

7 files changed

+416
-468
lines changed

page/code-organization/beware-anonymous-functions.md

+18-29
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: Beware Anonymous Functions
33
level: beginner
44
source: http://jqfundamentals.com/legacy
5-
attribution:
5+
attribution:
66
- jQuery Fundamentals
77
---
88

@@ -13,44 +13,33 @@ your handlers and callbacks.
1313
// BAD
1414
$( document ).ready(function() {
1515
16-
$("#magic").click(function( event ) {
16+
$( "#magic" ).click(function( event ) {
17+
$( "#yayeffects" ).slideUp(function() {
18+
// ...
19+
});
20+
});
1721
18-
$("#yayeffects").slideUp(function() {
19-
20-
// ...
21-
22-
});
23-
24-
});
25-
26-
$("#happiness").load( url + " #unicorns", function() {
27-
28-
// ...
29-
30-
});
22+
$( "#happiness" ).load( url + " #unicorns", function() {
23+
// ...
24+
});
3125
3226
});
3327
3428
// BETTER
3529
var PI = {
3630
37-
onReady : function() {
38-
39-
$("#magic").click( PI.candyMtn );
40-
41-
$("#happiness").load( PI.url + " #unicorns", PI.unicornCb );
42-
43-
},
44-
45-
candyMtn : function( event ) {
46-
47-
$("#yayeffects").slideUp( PI.slideCb );
31+
onReady: function() {
32+
$( "#magic" ).click( PI.candyMtn );
33+
$( "#happiness" ).load( PI.url + " #unicorns", PI.unicornCb );
34+
},
4835
49-
},
36+
candyMtn: function( event ) {
37+
$( "#yayeffects" ).slideUp( PI.slideCb );
38+
},
5039
51-
slideCb : function() { ... },
40+
slideCb: function() { ... },
5241
53-
unicornCb : function() { ... }
42+
unicornCb: function() { ... }
5443
5544
};
5645

0 commit comments

Comments
 (0)