I am writing an add-on. I need to modify the existing javascript/jquery in some ways. It calculates a price based on inputs. Pseudocode (original js I need to modify):
input.onEvent
get Input Values
calculate 'price' from input values
I need to modify the calculated price. So I would need to modify the original js in a way like this:
modified price = triggerEvent('modifyThePrice', price)
In words: I need to call a hook, where other javascript then can do their work and modify the price if they need to (or maybe something like an event with an return statement)...
on request I'll also add more precise code..
$('form#buy').bind('price-update', function(){
/*
* a LOT of code, getting input, calculating price. at the end we have a var
*price which is numeric
*/
//What I need to do now
var modified_price = modifyPrice(price);
});
just that modifyPrice(price) has to call every other js on the page, so everyone has the chance to interact.
to the guys of you knowing wordpress: I need to do something that would be done in wp with:
$modified_price = apply_filters('modify_price', $price);
where everyone can bind an function to the 'modify-price' hook
I hope that helps to understand the question