Created
June 26, 2012 01:23
-
-
Save davidrichards/2992489 to your computer and use it in GitHub Desktop.
A basic closure example. Also here: http://bost.ocks.org/mike/chart/
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
function chart() { | |
var width = 720, // default width | |
height = 80; // default height | |
function my() { | |
// generate chart here, using `width` and `height` | |
} | |
my.width = function(value) { | |
if (!arguments.length) return width; | |
width = value; | |
return my; | |
}; | |
my.height = function(value) { | |
if (!arguments.length) return height; | |
height = value; | |
return my; | |
}; | |
return my; | |
} |
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
function SingleSelect() { | |
// These variables won't get lost to the select view | |
var x = 1; | |
function self() { | |
// initialization code goes here, if necessary | |
// like some jquery setup of the select | |
} | |
self.change = funciton() { | |
} | |
return self; | |
} | |
var mySelect = SingleSelect(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment