所以我想在我的构造函数中有一个方法。我这样称呼我的构造函数
new EnhancedTooltip($("taskPreview1"))
并将其定义为
///<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);
};
};
并得到EnhancedTooltip没有方法init的错误。那么我应该如何定义init。
另外,如果我想从 init 调用其他函数,我该怎么做。例如
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>");
};