Skip to content

Instantly share code, notes, and snippets.

@d48
Last active December 11, 2015 22:28
Show Gist options
  • Save d48/4669276 to your computer and use it in GitHub Desktop.
Save d48/4669276 to your computer and use it in GitHub Desktop.
rewrite addEvent function signature to work with removeEvent using variable that points to function
function openHandler(widgetTypeId, userWidgetId, displayOrder, savePrefUrl) {
// some stuff
Utils.addEvent(btnSave, 'click', function () {
btnSaveClick(widgetTypeId, userWidgetId, displayOrder, savePrefUrl);
});
}
function btnSaveClick(typeId, widgetId, order, url) {
// definition
}
/* Can be rewritten to below? */
var saveClickHandle = function() {
btnSaveClick(widgetTypeId, userWidgetId, displayOrder, savePrefUrl);
}
Utils.addEvent(btnSave, 'click', saveClickHandle);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment