Skip to content
This repository was archived by the owner on Jan 13, 2022. It is now read-only.
oatkiller edited this page Sep 13, 2010 · 2 revisions

before lives on the function prototype. call it passing another function. it returns a function that wraps the first function with the second. if the second function returns truthy, the first function is called.

before is best explained by code:

(function () {

// define submit the form as a function that 
// submits your form, but first confirms with the user. 
var submit_the_form = function () {
	my_form.submit();
// use o.curry to turn a call into window.confirm into 
// a function that calls window.confirm with 'are you sure?'
}[o.before](confirm[o.curry]('are you sure?'));

// the users sees a confirm box. if they OK it, the form is submitted, otherwise not
submit_the_form();

})();
Clone this wiki locally