I have the following Javascript function:
function MyPseudoClass(){
this.initConfirmationSheet = function initConfirmationSheet(myDiv){
//foo
//bar
//etc.
}
//foo
function setUpGUI(){
var myDiv = document.getElementById(DivForDiagram);
myDiv.innerHTML = ""; //Clear contents of DIV for subsequent Diagram drawing.
confSheetDiagramRef = GO(go.Diagram, DivForDiagram, // the DIV HTML element
{
initialContentAlignment: go.Spot.Center,
initialAutoScale:go.Diagram.Uniform,
"toolManager.mouseWheelBehavior": go.ToolManager.WheelZoom
});
confSheetDiagramRef.initialContentAlignment = go.Spot.Center;
confSheetDiagramRef.undoManager.isEnabled = true;
confSheetDiagramRef.isReadOnly = true;
var texttemplate = GO(go.Node, "Horizontal",
GO(go.TextBlock,
new go.Binding("text", "text"),
new go.Binding("font", "fontType"),
new go.Binding("textAlign", "textAlign")
),
new go.Binding("location", "shapePosition"),
new go.Binding("angle", "rotation"),
new go.Binding("width", "width"),
new go.Binding("height", "height")
)
var imagetemplate = GO(go.Node, "Horizontal",
GO(go.Picture,
new go.Binding("text", "text"),
new go.Binding("font", "fontType"),
new go.Binding("location", "position"),
new go.Binding("angle", "rotation"),
new go.Binding("width", "width"),
new go.Binding("source", "text"),
new go.Binding("height", "height"),
new go.Binding("maxSize", "bounds")
)
)
var templmap = new go.Map("string", go.Node);
templmap.add("text", texttemplate);
templmap.add("image", imagetemplate);
confSheetDiagramRef.nodeTemplateMap = templmap;
confSheetDiagramRef.addDiagramListener('InitialLayoutCompleted', function(e){
alert("in listener!");
generateImages(700,100);
})
}
function generateImages(){
//foo
//bar
this.initConfirmationSheet('myDiv');
}
}
MyPseudoClass
is called in the following context:
nextConf = new MyPseudoClass(this);
nextConf.setInfo(confInfoVO, true, PasseDInEventDateTime_str, ParentRef.TicketPrintLayout, false);
nextConf.printAllConfirmations(ParentRef.DivName, numConfirmations);
And I get the following error: TypeError: this.initConfirmationSheet is not a function
I am not sure why the first function is not in the scope of the second.
Especially because the first function is available to another function within MyPseudoClass
:
this.thirdFunction = function thirdFunction(divName){
this.initConfirmationSheet(divName);
}
Is it because this function is defined, or attached to the instance of this class? as opposed to the other which is not defined with this.functionName
?