Skip to content

Instantly share code, notes, and snippets.

@ryana
Created July 13, 2010 16:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryana/474090 to your computer and use it in GitHub Desktop.
Save ryana/474090 to your computer and use it in GitHub Desktop.
var myObj = {
number: 10,
createElementsPType: function() {
new_element.click(this.showNumber.bind(this));
}
createElementsjQuery: function() {
new_element.click(this.showNumber);
},
showNumber: function() {
// in jQuery, this is element not myObj
// in pType, this == myObj because of bind
alert(this.number);
}
newElement: function() {
// do stuff and return a new element
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment