0

我真的不知道这是kendo ui对这个的支持。

我想在模板中写一个JQuery函数kendo ui

这是示例

<script type="text/x-kendo-template" id="someId">
#
 $(document).ready(function () {

 $('#textfield1').attr('required');

});
#
<script> 

问题是哈希(“#”)标记给了我一个错误,因为剑道 UI 使用哈希标记来分隔剑道 UI 中的 JavaScript 和 HTML。那么如何在上面的示例中添加哈希标记。有人能帮我吗 ??

4

3 回答 3

5

您可以使用反斜杠作为转义字符:

<script id="javascriptTemplate" type="text/x-kendo-template">
    <h4>#= $("\#theSpan").text()  #</h4>
</script>

演示

PS 我认为您不需要 document.ready,因为 KendoUI 代码(包括模板)依赖于 jQuery,并且仅在文档准备好后才运行。

于 2015-08-11T14:20:48.223 回答
1

您需要将每个代码行都放在开始和结束的 # 处。

#$(document).ready(function () {#
    #$('#textfield1').attr('required');#
 #}); #

来源:http ://demos.telerik.com/kendo-ui/templates/expressions

于 2015-08-11T04:39:07.500 回答
1

你的语法不正确!这是正确的

这里也是例子

http://demos.telerik.com/kendo-ui/templates/expressions

<script type="text/x-kendo-template" id="someId">

# $(document).ready(function () { #

#  $('#textfield1').attr('required'); #

# });#

<script> 
于 2015-08-11T04:40:29.153 回答