I wrote a javascript class with a function called 'setVisibilityOfWeekdaySelectbox'. I create the object and call the function init(). This function contains the code below. When i call init(), the function 'setVisibilityOfWeekdaySelectbox' will be called. When i change the frequency-selectbox firebug says the function cannot be found.
function ReportDefinition(options) {
this.options = options;
}
ReportDefinition.prototype.init = function(){
// change event of a select box
$("#frequency").change(function(){
this.setVisibilityOfWeekdaySelectbox();
this.getReportTemplate().setFrequencyInformation();
});
this.getReportTemplate().setFrequencyInformation();
this.setVisibilityOfWeekdaySelectbox();
});
ReportDefinition.prototype.setVisibilityOfWeekdaySelectbox = function (){
if($("#frequency").val() === undefined){
return;
};
if($("#frequency").val() === "WEEKLY"){
$("#weekday_div").show();
} else {
$("#weekday_div").hide();
}
}
How do I have to change the class to make it work?