Skip to content

Instantly share code, notes, and snippets.

@marekkalnik
Created November 24, 2011 14:52
Show Gist options
  • Save marekkalnik/1391507 to your computer and use it in GitHub Desktop.
Save marekkalnik/1391507 to your computer and use it in GitHub Desktop.
jQuery chaining and code scoping
var formHandling = function(formSelector) {
var onFormSubmit, onButtonClick, onQuantityChange;
jQuery(formSelector).bind('submit', onFormSubmit).end()
.find('button').bind('click', onButtonClick).end()
.find('input[name="quantity"]').bind('change', onQuantityChange);
onFormSubmit = function() { ... };
onButtonClick = function() { ... };
onQuantityChange = function() { ... };
}
formHandling();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment