Created
February 29, 2012 04:21
-
-
Save brandoncordell/1937686 to your computer and use it in GitHub Desktop.
My javascript-fu
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* jQuery - Singleton | |
*/ | |
var App; | |
App = { | |
awesomeLink: null, | |
ready: function() { | |
this.awesomeLink = $('#next-link'); | |
this.awesomeLink.bind('click', this.awesomeLinkClicked); | |
} | |
awesomeLinkClicked: function(event) { | |
event.preventDefault(); | |
this.openLightbox(); | |
}, | |
openLightbox: function() { | |
// do things to open lightbox | |
} | |
}; | |
$(document).ready(App.ready); | |
/* | |
* jQuery - Singleton in Coffeescript | |
*/ | |
App = | |
awesomeLink: null | |
ready: -> | |
@awesomeLink = $('#next-link') | |
@awesomeLink.bind 'click', @awesomeLinkClicked | |
awesomeLinkClicked: (event) -> | |
event.preventDefault() | |
@openLightbox() | |
openLightbox: -> | |
// do things to open lightbox | |
/* | |
* jQuery - Module Pattern | |
*/ | |
var App; | |
App = (function () { | |
var awesomeLink, | |
awesomeLinkClicked, | |
openLightbox; | |
awesomeLinkClicked = function() { | |
openLightbox(); | |
}; | |
openLightbox = function() { | |
// do things to open lightbox | |
}; | |
return { | |
ready: function() { | |
awesomeLink = $('#next-link'); | |
awesomeLink.bind('click', awesomeLinkClicked); | |
} | |
}; | |
})(); | |
$(function () { | |
App.ready(); | |
}); | |
/* | |
* jQuery - Module pattern in Coffeescript | |
*/ | |
App = -> | |
awesome = -> | |
openLightbox() | |
openLightbox = -> | |
// do things to open lightbox | |
ready: -> | |
awesomeLink = $('#next-link') | |
awesomeLink.bind 'click', awesomeLinkClicked | |
$ -> | |
App.ready() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment