Skip to content

Instantly share code, notes, and snippets.

@tomconnors
Created July 5, 2016 14:13
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 tomconnors/24e14812c8cd41a0046151e82af5420d to your computer and use it in GitHub Desktop.
Save tomconnors/24e14812c8cd41a0046151e82af5420d to your computer and use it in GitHub Desktop.
shows event handler wrapping
var
// "appstate" object
obj = {},
// data-level onChange handler - doesn't deal w/ the dom.
onChange = function(newValue){ obj.attr = newValue; },
// start function that deals with the dom and calls the data-level event handler
start = function(handler){
$(".selector").on("change", function(e){
e.preventDefault();
handler(e.target.value);
});
};
start(onChange);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment