我想将 Kendo 模板作为变量传递给模板 Javascript 函数,以将 JS 函数的返回注入到跨度的类中。(对象是动态设置图标)。如:#=addFileExtensionIcon(#=DocType#)#
当前迭代导致加载 gif 无限期持续......
我可以这样做吗?如果不能,我的选择是什么?
@*//WF ITEM ATTACHMENTS TEMPLATE*@
<script id="itemAttachmentsTemplate" type="text/x-kendo-template">
<div class="attachment">
<span class='k-icon #=addFileExtensionIcon(#=DocType#)#'></span>
<h3>FILE NAME</h3>
<h3>#=DocType#</h3>
<h3>#=CreatedByUserName#</h3>
<div class="btn btn-link" id="">
<span class="k-icon k-i-download"> </span>
</div>
</div>
</script>
JS:
function addFileExtensionIcon(extension) {
switch (extension) {
case '.jpg':
case '.img':
case '.png':
case '.gif':
return ".k-i-image";
case '.doc':
case '.docx':
return ".k-i-file-doc";
case '.xls':
case '.xlsx':
return ".k-i-file-xls";
case '.pdf':
return ".k-i-file-pdf";
case '.zip':
case '.rar':
return ".k-i-file-zip";
default:
return ".k-i-file";
}
}
用这个替换你的代码。
<script id="itemAttachmentsTemplate" type="text/x-kendo-template">
<div class="attachment">
<span class='k-icon #=addFileExtensionIcon(DocType)#'></span>
<h3>FILE NAME</h3>
<h3>#=DocType#</h3>
<h3>#=CreatedByUserName#</h3>
<div class="btn btn-link" id="">
<span class="k-icon k-i-download"> </span>
</div>
</div>
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句