Created
November 26, 2013 01:09
-
-
Save meowsus/7651809 to your computer and use it in GitHub Desktop.
Refactor me plz
This file contains 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
eventListener = function (widget) { | |
widget.$postalCode.one('focus', function () { | |
applyValidationRules(widget); | |
}); | |
widget.$country.on('change', function () { | |
applyValidationRules(widget); | |
}); | |
widget.$parentForm.on('submit', function () { | |
applyValidationRules(widget); | |
}); | |
}, |
That's about it.
eventListener = function (widget) {
function applyRules () {
applyValidationRules(widget);
}
widget.$postalCode.one('focus', applyRules);
widget.$country.on('change', applyRules);
widget.$parentForm.on('submit', applyRules);
},
eventListener=function(w){
(function(o,f){for(k in o)f(k,o[k]);})(
{'focus':w.$postalCode.one,'change':w.$country.on,'submit':w.$parentForm.on},
function(k,v){v.call(k,applyValidationRules(w))});
},
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Rename the function to setListeners.