By bloid
via code.google.com
Published: Jan 06 2008 / 22:47
jQuery AOP is a very small plugin that adds AOP features to javascript. It allows to add advices (Before, After and Around) to any global or instance function.
SaveShareSend
Tags: frameworks, javascript
Comments
alex.objelean replied ago:
I found this plugin very useful. My concrete situation was: adding client-side validation to a form using IceFaces JSF implementation. Unfortunately, when using ice:commandButton inside a form, the onSubmit() function is not called on the form, and the rendered submit button overrides the onclick function, thus it seemed impossible to add my validation script on the rendered form. My solution was to add an around advice to the submit button, decorating the onclick function with the validation script:
var refButton = ...// get the submit button reference
$.aop.around( {target: refButton, method: 'onclick'},
function(invocation) {
var refForm = $(this).parents("form:first")[0]; //get the form reference
var isValid = ..//perform client side validation on the form
return isValid ?invocation.proceed() : false; //proceed if the validation succeeded.
}
);
I find this approach completely unobtrusive and elegant, when you cannot change the rendered markup in order to add some behavior.
Voters For This Link (13)
Voters Against This Link (0)