我真的不知道kendo ui
支持这个。
我想在JQuery
模板中编写kendo ui
函数
以下是示例
<script type="text/x-kendo-template" id="someId">
#
$(document).ready(function () {
$('#textfield1').attr('required');
});
#
<script>
事情是哈希(&#34;#&#34;)标记给我一个错误,因为kendo ui使用哈希标记在kendo UI中分离JavaScript和HTML。
那么如何在上面的例子中添加哈希标记呢。
有人能帮我吗 ??
答案 0 :(得分:5)
您可以使用反斜杠作为转义字符:
using System;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Enter your name, please: ");
string name = Console.ReadLine();
Console.WriteLine("Good choice, " + name);
Console.Write("Press F to feed yourself(+10) and D to drink some water(+10)");
Console.WriteLine(" ");
int hunger = 60;
int thirst = 60;
while (hunger < 101)
while (hunger > 1)
while (thirst < 101)
while (thirst > 1)
if (!(Console.KeyAvailable && Console.ReadKey(true).Key == ConsoleKey.F))
{
System.Threading.Thread.Sleep(500);
{
hunger = hunger + 10;
Console.Write("Food: {0:0.0}".PadRight(15), hunger);
Console.Write("Water: {0:0.0}".PadRight(70), thirst);
}
}
if (!(Console.KeyAvailable && Console.ReadKey(true).Key == ConsoleKey.F))
{
System.Threading.Thread.Sleep(500);
{
thirst = thirst + 10;
Console.Write("Food: {0:0.0}".PadRight(15), hunger);
Console.Write("Water: {0:0.0}".PadRight(70), thirst);
}
}
{
System.Threading.Thread.Sleep(5000);
Console.Write(" ");
{
hunger = hunger - 2;
thirst = thirst - 4;
Console.Write("Food: {0:0.0}".PadRight(15), hunger);
Console.Write("Water: {0:0.0}".PadRight(70), thirst);
}
if (thirst < 1)
{
Console.Write("You died from dehydration, RIP:" + name);
System.Threading.Thread.Sleep(3000);
{
System.Environment.Exit(1);
}
}
if (thirst > 101)
{
Console.Write("You died from drinking too much, RIP:" + name);
System.Threading.Thread.Sleep(3000);
{
System.Environment.Exit(1);
}
}
}
if (hunger < 1)
{
Console.Write("You died from not eating enough, RIP:" + name);
System.Threading.Thread.Sleep(3000);
{
System.Environment.Exit(1);
}
}
if (hunger > 101)
{
Console.Write("You died from over feeding, RIP:" + name);
System.Threading.Thread.Sleep(3000);
{
System.Environment.Exit(1);
}
}
}
}
}
P.S。我不认为你需要这个文件。因为KendoUI代码(包括模板)依赖于jQuery而且只在文档准备好后运行。
答案 1 :(得分:1)
您需要在每个代码行中打开和关闭#。
#$(document).ready(function () {#
#$('#textfield1').attr('required');#
#}); #
答案 2 :(得分:1)
你的语法不正确!这是正确的
这里也是一个例子
http://demos.telerik.com/kendo-ui/templates/expressions
<script type="text/x-kendo-template" id="someId">
# $(document).ready(function () { #
# $('#textfield1').attr('required'); #
# });#
<script>