Hi;
For a few controls such as combobox, form, linkbuttons, I need to be able to process an event firstly for all objects (onLoadSuccess) with some 'middleware' and then afterwards allow individual elements to optionally catch the original event and do some local processing (afterSuccess).
This is what I have tried, but it does not appear to work:
var onLoadSuccess = $.fn.form.methods.onLoadSuccess;
$.extend($.fn.form.methods, {
onLoadSuccess: function(jq){
return jq.each(function(){
onLoadSuccess.call($.fn.form.methods, $(this));
var opts = $(this).form('options');
if (opts.afterSuccess){ opts.afterSuccess.call(this);}
})
}
})
$.extend($.fn.form.defaults, {
onLoadSuccess:function(jq){
console.log('always do....');
}
})
$('#ff).form({
afterSuccess: function(){
console.log('do if the element wants to..');
}
})
How can I achieve this ?