Unable to Customize Kendo Calendar Month templates with Knockout Kendo JS Binding

て烟熏妆下的殇ゞ 提交于 2019-12-11 20:24:27

问题


I have customized the Kendo Calendar Month Template Reference found Here with out knockout-kendo.js. Official Kendo Reference from Here.

The problem is when i use the below code in knockout-kendo.js binding its not getting compiled. Take a look at this Knockout-kendo.js with Calendar at fiddle. If i remove the month view template code, its working. How do i resolve this with 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());
                },
            });

The Error is below :

So, the Question is How to Use Month View in Knockout-Kendo.js binding?

Update:


回答1:


Inside of your Kendo Template you need to escape your quotes. So, you can use &quot; rather than just the ".

Like:

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>' +
                             '# } #'

You can move the template string into your view model, if it helps.

Here is an updated fiddle: http://jsfiddle.net/rniemeyer/bfycstr4/



来源:https://stackoverflow.com/questions/25721306/unable-to-customize-kendo-calendar-month-templates-with-knockout-kendo-js-bindin

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!