将值传递给 kendoWindow 模板
Passing value to a kendoWindow template
给定以下模板和函数,我如何传递函数参数 contentText
以显示在占位符 ###
的模板 #password-validation
中?
模板
<script id="password-validation" type="text/x-kendo-template">
<p style="font-size: 12px; padding: 10px">
###
</p>
<div style="text-align: right">
<button class="password-ok k-button">OK</button>
</div>
</script>
函数
function PasswordValidation(contentText) {
var kendoWindow = $("<div />").kendoWindow({
actions: ["Close"],
title: "Password validation",
resizable: false,
modal: true
});
kendoWindow.data("kendoWindow")
.content($("#password-validation").html())
.center().open();
kendoWindow
.find(".password-ok")
.click(function () {
kendoWindow.data("kendoWindow").close();
})
.end()
}
解决方法如下:
<script id="password-validation" type="text/x-kendo-template">
<p style="font-size: 12px; padding: 10px">
#=data#
</p>
<div style="text-align: right">
<button class="password-ok k-button">OK</button>
</div>
</script>
和功能:
function PasswordValidation(contentText) {
var kendoWindow = $("<div />").kendoWindow({
actions: ["Close"],
title: "Password validation",
resizable: false,
modal: true
});
var template = kendo.template($("#password-validation").html());
kendoWindow.data("kendoWindow")
.content(template(contentText))
.center().open();
kendoWindow
.find(".password-ok")
.click(function () {
kendoWindow.data("kendoWindow").close();
})
.end()
}
给定以下模板和函数,我如何传递函数参数 contentText
以显示在占位符 ###
的模板 #password-validation
中?
模板
<script id="password-validation" type="text/x-kendo-template">
<p style="font-size: 12px; padding: 10px">
###
</p>
<div style="text-align: right">
<button class="password-ok k-button">OK</button>
</div>
</script>
函数
function PasswordValidation(contentText) {
var kendoWindow = $("<div />").kendoWindow({
actions: ["Close"],
title: "Password validation",
resizable: false,
modal: true
});
kendoWindow.data("kendoWindow")
.content($("#password-validation").html())
.center().open();
kendoWindow
.find(".password-ok")
.click(function () {
kendoWindow.data("kendoWindow").close();
})
.end()
}
解决方法如下:
<script id="password-validation" type="text/x-kendo-template">
<p style="font-size: 12px; padding: 10px">
#=data#
</p>
<div style="text-align: right">
<button class="password-ok k-button">OK</button>
</div>
</script>
和功能:
function PasswordValidation(contentText) {
var kendoWindow = $("<div />").kendoWindow({
actions: ["Close"],
title: "Password validation",
resizable: false,
modal: true
});
var template = kendo.template($("#password-validation").html());
kendoWindow.data("kendoWindow")
.content(template(contentText))
.center().open();
kendoWindow
.find(".password-ok")
.click(function () {
kendoWindow.data("kendoWindow").close();
})
.end()
}