Last active
December 21, 2015 19:09
-
-
Save tatat/6352034 to your computer and use it in GitHub Desktop.
on と同時に trigger
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
// その関数だけ実行するやつ | |
$.fn.onWithCall = function() { | |
var args = Array.prototype.slice.call(arguments), | |
listener = args[args.length - 1]; | |
return this.on.apply(this, args).each(function() { | |
listener.call(this, $.Event(args[0])); | |
}); | |
}; | |
// trigger するやつ | |
$.fn.onWithCall = function() { | |
return this.on.apply(this, arguments).trigger(arguments[0]); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment