2

我正在尝试在我的页面上实现一些 KendoUI Web 小部件,但这些小部件没有按预期工作并且存在以下问题:

  1. Editor初始化正常,但是很少有问题,例如当您将鼠标悬停在突出显示的选项上时,但是当您移开时,它应该恢复正常,而事实并非如此
  2. 如果我刷新页面几次而不是某些时间Editor初始化很好但有时它不会
  3. 其他小部件kendoDatePicker();kendoDropDownList();甚至没有初始化
  4. 我的 JQ 表单验证在此页面上也不起作用

此外,在 chrome 控制台中,我 Uncaught TypeError: Cannot call method 'removeClass' of undefined在第 23679 行出现以下错误,kendo.web.js其中指出:

if (value !== DropDownList.fn.value.call(that)) {
            that.text(that.options.title);
            that._current.removeClass("k-state-selected");//This is line # 23679
            that.current(null);
            that._oldIndex = that.selectedIndex = -1;
        }

我在页面上包含以下脚本:

<script src="/Scripts/jquery-1.7.1.js"></script>
<script src="/Scripts/jquery.unobtrusive-ajax.min.js"></script>
<script src="/Scripts/jquery.validate.min.js"></script>
<script src="/Scripts/modernizr-2.5.3.js"></script>
<script src="/Scripts/kndu/kendo.web.js"></script>
…
….

<script>
    $(document).ready(function () {
        $("#editor").kendoEditor({
            tools: [
                "bold",
                "italic",
                "underline",
                "strikethrough",
                "justifyLeft",
                "justifyCenter",
                "justifyRight",
                "justifyFull", "insertUnorderedList",
                "insertOrderedList",
                "formatBlock",
                "createLink",
                "unlink",
                "insertImage",
                "insertHtml",
                "viewHtml",
                {
                    name: "customTool",
                    tooltip: "Format as Code",
                    exec: function (e) {
                        var editor = $(this).data("kendoEditor");
                        editor.exec("inserthtml", { value: "<pre>" });
                    }
                }],

        });
        $("#date").kendoDatePicker();
        $("#categry").kendoDropDownList();


        $("#newpost").validate({
            rules: {
                ttle: {
                    maxlength: 150,
                    required: true,
                    onlyChars: true
                },
                smmry: {
                    maxlength: 250,
                    required: true
                },
                editor: {
                    maxlength: 35,
                    required: true
                },
                categry: {
                    required: true
                }
            }
        });
    });
    $.validator.addMethod('onlyChars', function (value) {
        return /^[a-zA-Z ]+$/.test(value);
    }, 'Please enter a valid name with only alphabets');
</script>
4

1 回答 1

3

关于insertHTML文档在这里说:

insertHtml 工具需要一组文本值对。一个分隔符可以包含多次。

所以你应该有类似的东西:

$("#editor").kendoEditor({
    tools: [
        ...
        "insertHtml",
        ...
    ],
    insertHtml: [
        { text: "label 1", value: "<p>snippet 1</p>" },
        { text: "label 2", value: "<p>snippet 2</p>" }
    ]
});
于 2013-04-08T20:42:14.143 回答