Skip to content

Commit

Permalink
Style and typography fixes, and code style adherence in the Code Orga…
Browse files Browse the repository at this point in the history
…nization section. Fixes #287.
  • Loading branch information
Markus Amalthea Magnuson authored and ajpiano committed Mar 14, 2013
1 parent e8e5b42 commit 65bbfb2
Show file tree
Hide file tree
Showing 7 changed files with 416 additions and 468 deletions.
47 changes: 18 additions & 29 deletions page/code-organization/beware-anonymous-functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: Beware Anonymous Functions
level: beginner
source: http://jqfundamentals.com/legacy
attribution:
attribution:
- jQuery Fundamentals
---

Expand All @@ -13,44 +13,33 @@ your handlers and callbacks.
// BAD
$( document ).ready(function() {
$("#magic").click(function( event ) {
$( "#magic" ).click(function( event ) {
$( "#yayeffects" ).slideUp(function() {
// ...
});
});
$("#yayeffects").slideUp(function() {
// ...
});
});
$("#happiness").load( url + " #unicorns", function() {
// ...
});
$( "#happiness" ).load( url + " #unicorns", function() {
// ...
});
});
// BETTER
var PI = {
onReady : function() {
$("#magic").click( PI.candyMtn );
$("#happiness").load( PI.url + " #unicorns", PI.unicornCb );
},
candyMtn : function( event ) {
$("#yayeffects").slideUp( PI.slideCb );
onReady: function() {
$( "#magic" ).click( PI.candyMtn );
$( "#happiness" ).load( PI.url + " #unicorns", PI.unicornCb );
},
},
candyMtn: function( event ) {
$( "#yayeffects" ).slideUp( PI.slideCb );
},
slideCb : function() { ... },
slideCb: function() { ... },
unicornCb : function() { ... }
unicornCb: function() { ... }
};
Expand Down
Loading

0 comments on commit 65bbfb2

Please sign in to comment.