I dont understand why/ how to accomplish this fairly simple thing. If someone could explain it that would be great.
function Module(config) {
this.host = {Collapse: $('<a href="#" class="collapse">C</a>')};
function EnableCollapse() {
//I need to access host.Collapse here
this.host.Collapse.hide(); // Throws error
host.Collapse.hide(); //Throws error
}
}
How do I access Collapse inside this function? Or should these work and perhaps i have something else wrong?
Assuming you’re calling
Moduleas a constructor, you could makeEnableCollapsea property of the object rendered.Otherwise, if you intend to keep
EnableCollapseprivate, you manually set itsthisvalue.Ultimately, the value of
thiswill depend on how you’re callingModuleandCollapse.