title: JQuery/Javascript Hooks
body: <p>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):</p>
  
  <pre><code>input.onEvent
      get Input Values
      calculate 'price' from input values
  </code></pre>
  
  <p>I need to modify the calculated price. So I would need to modify the original js in a way like this:</p>
  
  <pre><code>    modified price = triggerEvent('modifyThePrice', price)
  </code></pre>
  
  <p>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)...</p>
  
  <p>on request I'll also add more precise code..</p>
  
  <pre><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);
  });
  </code></pre>
  
  <p>just that modifyPrice(price) has to call every other js on the page, so everyone has the chance to interact.</p>
  
  <p>to the guys of you knowing wordpress: I need to do something that would be done in wp with:</p>
  
  <pre><code>$modified_price = apply_filters('modify_price', $price);
  </code></pre>
  
  <p>where everyone can bind an function to the 'modify-price' hook</p>
  
  <p>I hope that helps to understand the question</p>