http://jsfiddle.net/2yw4o6z8/1/
public players(container: any, options: any, that: any,selectedoptions) {
$(".displayInlineBlock").removeClass("SWIMMINGumentMobileDiplay");
let SWIMMINGImageMobile = "SWIMMINGumentMobile";
let extensionType = {
".pdf": "pdfMobile",
".ppt": "pptMobile",
".xls": "xlsMobile",
".xlsx": "xlsMobile",
".SWIMMING": "SWIMMINGumentMobile",
".SWIMMINGx": "SWIMMINGumentMobile",
".msg": "mailMobile"
};
let lastIndex = options.model.SWIMMINGumentName.lastIndexOf(".");
SWIMMINGImageMobile = extensionType[options.model.SWIMMINGumentName.slice(lastIndex).toLowerCase()];
if (typeof options.model.SWIMMINGumentMobile != "undefined" && options.model.SWIMMINGumentMobile != "") {
SWIMMINGImageMobile = options.model.SWIMMINGumentMobile;
}
if (typeof SWIMMINGImageMobile == "undefined") {
SWIMMINGImageMobile = "newDocMobile";
}
let kendotxtMenu = "";
if (options.model.isElfDoc == true) {
kendotxtMenu = "SWIMMINGumentMobileDiplay";
}
//"isElfDoc":true;
let input = $("<span class='" + SWIMMINGImageMobile + " displayInlineBlock " + options.model.SWIMMINGumentlength + " " + kendotxtMenu + " ' ></span><ul class='fileTypeHolder' id='fileTypeMobiles' style='display: none;'><li class='fileTypeHolderTitle'>ELF Document Type</li><li><span class='SWIMMINGumentMobile displayInlineBlock' (click)='browseFileType(SWIMMING)'></span></li> <li><span class='xlsMobile displayInlineBlock' (click)='browseFileType('xls')'></span></li> <li><span class='pptMobile displayInlineBlock'(click)='browseFileType('ppt')'></span></li> <li><span class='pdfMobile displayInlineBlock' (click)='browseFileType('pdf')'></span></li><li><span class='newDocMobile displayInlineBlock' (click)='browseFileType('newSWIMMING')'></span></li><li><span class='mailMobile displayInlineBlock' (click)='browseFileType('mail')'></span></li><li class='fileTypeHolderCloseBtn'> <button id='CloseBtn' class='commonBtn'>Close</button></ul>");
input.appendTo(container);
// <button class='commonBtn' id='CloseBtn'>Close</button>
this.selectedoptions = null;
this.selectedoptions = options;
$("#fileTypeMobiles").kendoContextMenu({
target: ".SWIMMINGumentMobileDiplay",
showOn: "click",
open: function(e) {
// console.log($(this).index(this));
// console.log($(this).index());
},
select: function(e) {
//console.log(e.item.firstElementChild);
//console.log(e.item.firstElementChild.firstElementChild.className);
var ReturnClassName = e.item.firstElementChild.firstElementChild.className
if (ReturnClassName == "commonBtn") {
return false;
}
let firstClass = $("." + options.model.SWIMMINGumentlength).attr('class').split(" ")[0];
var extensionType = {
"pdfMobile": "pdf",
"pptMobile": "ppt",
"xlsMobile": "xls",
"SWIMMINGumentMobile": "SWIMMING",
"newDocMobile": "default",
"mailMobile": "msg"
};
var classNames = "pdfMobile pptMobile xlsMobile SWIMMINGumentMobile mailMobile newDocMobile";
var classes = $("." + options.model.SWIMMINGumentlength).attr('class').split(" ");
$("#" + options.model.SWIMMINGumentlength).val("." + extensionType[ReturnClassName.split(" ")[0]]);
options.model.SWIMMINGumentName = "";
options.model.SWIMMINGumentName = "." + extensionType[ReturnClassName.split(" ")[0]];
options.model.isElfDoc = false;
for (var c = 0; c < classes.length; c++) {
if (classNames.includes(classes[c])) {
$("." + options.model.SWIMMINGumentlength).removeClass(classes[c]);
}
}
options.model.SWIMMINGumentMobile = ReturnClassName.split(" ")[0];
$("." + options.model.SWIMMINGumentlength).addClass(e.item.firstElementChild.firstElementChild.className);
//$("."+options.model.SWIMMINGumentId).addClass("displayInlineBlock");
$("." + options.model.SWIMMINGumentlength).addClass("SWIMMINGumentMobileDiplay");
let data_source = that.gridkendo._dataSource.data();
for (let d = 0; d < data_source.length; d++) {
if (data_source[d].isElfDoc == true && data_source[d].elfDocID == "") {
that.gridkendo.enableSaveDocument(false);
}
}
}
});
}
describe("Our data array", function() {
it("has four items", function() {
expect(players()).toBe(0);
});
});
答案 0 :(得分:0)
主要问题是JSFiddle没有为您编译TypeScript到JavaScript。
尝试使用TypeScript游乐场,如果需要,将JavaScript复制到JSFiddle。
你还没有将公共方法包含在一个类中......将你的players
方法包装在一个类中......即。
class Example {
public players(...) { }
}
您需要创建Example
类的实例才能使用该方法,除非您将其设为静态:
const example = new Example();
example.players(...);
您还需要指定属性&#34; selectedoptions&#34;当你突然引用它时,你会惊讶编译器。在课堂内添加:
private selectedoptions: any;
您还需要做一些工作才能使方法返回值。你没有传递任何论据,所以你在整个商店都没有定义。
如果你得到它&#34;运行&#34;,由于options
未定义,你会看到测试失败:
http://jsfiddle.net/om4pc7s8/1/
我希望这会有所帮助。