首页 > 解决方案 > 剑道对话最大长度

问题描述

我正在尝试使用剑道对话框作为用户输入的基本提示。

这是我的代码(类似于Telerik 给出的说明):

return $("<div></div>").kendoPrompt({
   title: "Enter Reason",
   content: "Enter a reason for your action",
   width: 400
}).data("kendoPrompt").open().result;

我需要在生成的文本框中设置最大输入长度(400 个字符)。任何人都可以帮忙吗?

标签: kendo-ui

解决方案


有一个解决方法,首先隐藏默认输入,然后在内容上添加剑道模板。Promise 将接收输入的数据。

像这样的东西:

<style>
   .k-prompt-container .k-textbox {
      display: none;
   }
</style>

<button id="promptBtn" class="k-button">myprompt</button>   
<script id="test" type="text/x-kendo-template">
    <p>Please enter text, max 10 length</p>
    <input class="k-textbox" maxlength="10"/>
</script>

$('#promptBtn').on('click', function () {
    window.myPrompt().then(function (data) {
        console.log(data);
    }, function () {
        console.log('cancel');
    })
});

function myPrompt() {
    return $('<div></div>').kendoPrompt({
        title: 'Kendo prompt',
        value: '',
        content: kendo.template($('#test').html()),
    }).getKendoPrompt().open().result;
}

示例:剑道自定义提示


推荐阅读