Hi javascript developers,
Is there a way to reduce the boilerplate required to define a function in jquery?
(My example is with a callback but it could apply to any anon function.)
$('#dialog').load('/index.cgi',{p:'myform'}, function(){ ajaxify_form() });
What I would like is to do
$('#dialog').load('/index.cgi',{p:'myform'}, $.f(){ ajaxify_form() });
Thanks in advance.
The boilerplate you have isn’t required. Just pass in the function directly:
is for all intents and purposes equivalent to:
except that the meaning of
thiswill differ within the function.Note: don’t do it this way:
as that does something completely different. Instead of passing in the function you pass in what the function returns.