将值传递给kendoWindow模板

时间:2015-11-25 11:00:01

标签: kendo-ui kendo-window

鉴于以下模板和函数,我如何传递函数参数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()
}

1 个答案:

答案 0 :(得分:5)

这是解决方案:

<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()
}
相关问题