javascriptjqueryknockout.jskendo-uiknockout-kendo

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


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 :

enter image description here

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

Update:

Error


Solution

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