Skip to content

Instantly share code, notes, and snippets.

@tatat
Last active December 21, 2015 19:09
Show Gist options
  • Save tatat/6352034 to your computer and use it in GitHub Desktop.
Save tatat/6352034 to your computer and use it in GitHub Desktop.
on と同時に trigger
// その関数だけ実行するやつ
$.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