So I would like to have a method inside my constructor. I call my constructor like this
new EnhancedTooltip($("taskPreview1"))
and define it as so
///<var> Represents the controls</var>
var EnhancedTooltip = function (toolTipObject) {
///<field name="alignment" type="Number">.</field>
this.alignment = 2;
///<field name="associatedControl" type="Number">.</field>
this.associatedControl = toolTipObject;
///<field name="caption" type="Number">.</field>
this.caption = "Let's see how this works";
///<field name="description" type="Number">.</field>
this.description;
///<field name="enableEffects" type="Number">.</field>
this.enableEffects = false;
///<field name="fadeAnimationSpeed" type="Number">.</field>
this.fadeAnimationSpeed = 500;
///<field name="image" type="Number">.</field>
this.image;
///<field name="minimumHeight" type="Number">.</field>
this.minimumHeight = 100;
///<field name="minimumWidth" type="Number">.</field>
this.minimumWidth = 200;
///<field name="objectName" type="String">.</field>
this.objectName = $("taskToolTip");
///<field name="padding" type="Number">.<field>
this.padding = 5;
///<field name="tailAngle" type="Number">.</field>
this.tailAngle;
///<field name="tailDiamensions" type="Object">.</field>
this.tailDimensions = new Size(15, 0);
EnhancedTooltip.init();
this.init = new function () {
///<summary>Initializes the class EnhancedTooltip.<summary>
console.log(EnhancedToolTip.objectName);
};
};
and getting the error that EnhancedTooltip has no method init. So how should I define init.
Also if I want to call other functions from init how would I do that. For example
this.addToolTipElements = function() {
$("#workspaceContainer").append("<div id = taskToolTip class = taskToolTip</div>");
this.objectName.append("<canvas id = toolTipCanvas class = toolTipCanvas </canvas>");
this.objectName.append("<div id = toolTipCaption class = toolTipCaption>" + this.caption + "</div>");
};
That’s because “EnhancedTooltip” is your constructor function, and it doesn’t have an “init” property. However, the object being constructed (
this) does:and inside the function:
Also, it’s not
new function, it’s justfunction:edit ah and, as Sirko points out, call the function after defining it.