Automating JS Behavior Registration

Written by on May 18th, 2007 in Ajax News.

Gabriel Handford has created a behavior.js script that allows you to unobtrusively automate Event.observe’tion.

Magic is in naming conventions, so that:

HTML:

  1.  
  2. <a class=”bvr-observe-click-xhrTheFunction” href=”/the/href”>The link</a>
  3.  

takes care of:

JAVASCRIPT:

  1.  
  2. Event.observe(theLinkElement, “click”, function(event) { xhrTheFunction(event) });
  3.  

Source: Ajaxian
Original Article: http://ajaxian.com/archives/automating-js-behavior-registration

Leave a Reply

You must be logged in to post a comment.



Site Navigation