I know you can invoke a function on click by:
$(".foo").on("click", function);
// Assume 'function' is an actual function declared elsewhere.
But is there a way to pass a param into the function using that style? I know you can do:
$(".foo").on("click", {namespace: this}, function (e) {
var that = e.data.namespace;
that.function(that);
});
But this is not how I want to write it. I want to call an already created function on a .click event and pass params to it using the one-line notation of the top example. How do I do this?
Besides you can also use
bind:This method was added to ECMA-262, 5th edition and might have compatibility problems with old browsers. You may check MDN for possible workarounds.