RSS
 

Archive for August, 2013

More readable Javascript code

30 Aug
// BAD
$( document ).ready(function() {
 
    $( "#magic" ).click(function( event ) {
        $( "#yayeffects" ).slideUp(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 );
    },
 
    slideCb: function() { ... },
 
    unicornCb: function() { ... }
 
};
 
$( document ).ready( PI.onReady );

Source:http://learn.jquery.com/code-organization/beware-anonymous-functions/

 
 

gem install worldpeace

06 Aug

What’s the one gem you wish existed but doesn’t?

https://rubygems.org/search?utf8=%E2%9C%93&query=worldpeace

 
 
 
Premium Wordpress Plugin