But I'm trying to extract that anon function. But I don't know how to pass the variable 'this' which is the third argument in the subscribe method above (i.e. 'medical_directive').
I have this but it doesn't work. How can I make this work?
/** * PubSubs subscribers: when user clicks on input id="medical_directive". * This enables/disables id="medical_directive_spouse" */ MyUT.oPubSubs.subscribe( 'onChangeMedicalDirective', $('').enableSpouseCheckbox(this), 'medical_directive'); $.fn.enableSpouseCheckbox = function(that) { var iMedicalDirective = $('input#' + that + ':checked').length; if ( iMedicalDirective >= 1 ) { //enable input id='medical_directive_spouse' $('#' + that + '_spouse').prop('disabled', false); } else { //uncheck the id='medical_directive_spouse' $('#' + that + '_spouse').attr('checked', false); } };
So, how do I "you can also designate a Jquery function to call , but you do not need a jquery function for this to operate"?
The reason I want to extract that code to its own defined function because there were other events that was using similar code in that function block. :) I just saw repetitive code.
Ok, I see.
So, how do I "you can also designate a Jquery function to call , but you do not need a jquery function for this to operate"?
The reason I want to extract that code to its own defined function because there were other events that was using similar code in that function block. :) I just saw repetitive code.