Search code examples
kendo-uikendo-window

Passing value to a kendoWindow template


Given the below template and function, how can I pass the function argument contentText to display in the template #password-validation at the placeholder ###?

Template

<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

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()
}

Solution

  • here is solution:

    <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>
    

    and function:

    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()
    }