【问题标题】:Unable to Customize Kendo Calendar Month templates with Knockout Kendo JS Binding无法使用 Knockout Kendo JS Binding 自定义 Kendo Calendar Month 模板
【发布时间】:2014-09-08 09:39:04
【问题描述】:

我已经自定义了 Kendo Calendar Month Template 参考找到 Here with out knockout-kendo.js。来自Here的官方剑道参考。

问题是当我在knockout-kendo.js binding its not getting compiled 中使用以下代码时。看看这个Knockout-kendo.js with Calendar at fiddle。如果我删除month view template code,它的工作。我如何用 knockout-kendo.js 解决这个问题?

           $("#calendar").kendoCalendar({
                dates: birthdays,
                month: {
                    // template for dates in month view
                    content: '# if (isInArray(data.date, data.dates, data) == "failure") { #' +
                                 '<div class="failure">' + '#= data.value #' + '</div>' +
                             '# } #' +
                             '# if (isInArray(data.date, data.dates, data) == "success") { #' +
                                 '<div class="success">' + '#= data.value #' + '</div>' +
                             '# } #' +
                             '# if (isInArray(data.date, data.dates, data) == "none") { #' +
                                 '<div class="none">' + '#= data.value #' + '</div>' +
                             '# } #'

                },
                change: function () {
                    scheduler.date(this.value());
                },
            });

错误如下:

那么,问题是如何在 Knockout-Kendo.js 绑定中使用月视图?

更新:

【问题讨论】:

    标签: javascript jquery knockout.js kendo-ui knockout-kendo


    【解决方案1】:

    在您的剑道模板中,您需要转义您的引语。因此,您可以使用&amp;quot; 而不仅仅是"

    喜欢:

    content: '# if (isInArray(data.date, data.dates, data) == &quot;failure&quot;) { #' +
                                     '<div class=&quot;failure&quot;>' + '#= data.value #' + '</div>' +
                                 '# } #' +
                                 '# if (isInArray(data.date, data.dates, data) == &quot;success&quot;) { #' +
                                     '<div class=&quot;success&quot;>' + '#= data.value #' + '</div>' +
                                 '# } #' +
                                 '# if (isInArray(data.date, data.dates, data) == &quot;none&quot;) { #' +
                                     '<div class=&quot;none&quot;>' + '#= data.value #' + '</div>' +
                                 '# } #'
    

    如果有帮助,您可以将模板字符串移动到您的视图模型中。

    这是一个更新的小提琴:http://jsfiddle.net/rniemeyer/bfycstr4/

    【讨论】:

    • 感谢您的时间和快速响应。它仍然给我一个错误。请在我的问题中查看我更新的图像。
    • 此行未编译 '&lt;div class=&amp;quot;failure&amp;quot;&gt;' + '#= data.value #' + '&lt;/div&gt;' +。第二行。
    • 在小提琴还是在哪里?小提琴工作正常,对吧?
    • 我对 isInArray 函数也做了一个小改动,所以它没有从参数中读取dates
    • 是的,这在小提琴中工作得非常好。我在 Visual Studio 2013 asp.net MVC 项目中使用。正如我上面提到的,只有我面临的问题。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-12-24
    • 2013-04-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多