Created
July 5, 2016 14:13
-
-
Save tomconnors/24e14812c8cd41a0046151e82af5420d to your computer and use it in GitHub Desktop.
shows event handler wrapping
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
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