I want to change css properties inside of a named function thant handles the click event. If I call .css in an anonymous function defined in the click event, it works. However, I want to call .css inside of a named function defined inside the handler function. Here's my code.
$(document).ready(function () {
$('#popup').click(partial(coolTransition, $(this)));
});
function coolTransition(elem) {
shrink();
function shrink() {
elem.css('background-color', '#000000');
}
}
//used to implement partial function application so that I can pass a handler reference that takes arguments.
//see http://stackoverflow.com/questions/321113/how-can-i-pre-set-arguments-in-javascript-function-call-partial-function-applic
function partial(func /*, 0..n args */ ) {
var args = Array.prototype.slice.call(arguments, 1);
return function () {
var allArguments = args.concat(Array.prototype.slice.call(arguments));
return func.apply(this, allArguments);
};
}
Thanks in advance for help.