surveyjs / survey-library

Free JavaScript form builder library with integration for React, Angular, Vue, jQuery, and Knockout.
https://surveyjs.io/form-library
MIT License
4.09k stars 795 forks source link

Uncaught SyntaxError: Unable to process binding "template: function(){return {name:"sectionTemplate",foreach:sections,templateOptions:{ deleteSection:deleteSection,openAddDocumentsDialog:openAddDocumentsDialog}} }" Message: Unexpected token ')' #2660

Open riyasomani12 opened 3 years ago

riyasomani12 commented 3 years ago

With the latest version, I got :

Uncaught SyntaxError: Unable to process binding "template: function(){return {name:"sectionTemplate",foreach:sections,templateOptions:{ deleteSection:deleteSection,openAddDocumentsDialog:openAddDocumentsDialog}} }"
Message: Unexpected token ')'
    at new Function (<anonymous>)
    at o (jquery.tmpl.min.js?v=1796624008301926680:10)
    at Function.template (jquery.tmpl.min.js?v=1796624008301926680:10)
    at a.$a.renderTemplateSource (knockout-3.5.1.js?v=1796624008301926680:138)
    at a.$a.a.ca.renderTemplate (knockout-3.5.1.js?v=1796624008301926680:119)
    at e (knockout-3.5.1.js?v=1796624008301926680:125)
    at u (knockout-3.5.1.js?v=1796624008301926680:128)
    at a.$.l (knockout-3.5.1.js?v=1796624008301926680:133)
    at Function.yd (knockout-3.5.1.js?v=1796624008301926680:55)
    at Function.zd (knockout-3.5.1.js?v=1796624008301926680:55)

I have used custome knockout.js file where i processed viewmodel and when i debugged code below code is giving error,

ko.bindingHandlers.modalDialogVisible = {
        init: function (element, valueAccessor) {
            var value = valueAccessor();
            $(element).jqm({
                modal: false,
                toTop: true    // fixes a bug in IE 8 compat mode (IE 7)
            });
        },
        update: function (element, valueAccessor) {
            var value = valueAccessor();
            if (value()) {
                var el = $(element);
                el.jqmShow();
            } else {
                $(element).jqmHide();
            }
        }
    };
ko.applyBindings(viewModel); - Specially this code exucting ubnormaly when used with knockout-3.5.1.j but its working fine with knockout-2.1.0.
mikekidder commented 3 years ago

Don't think this is SurveyJS issue.

Try

var value = ko.unwrap(valueAccessor());

And if your value is boolean

if (value === true) {
andrewtelnov commented 3 years ago

@riyasomani12 we need an example that allows us to reproduce the issue. Please create an example that shows the issue, in plunker and post it here.

Thank you, Andrew

riyasomani12 commented 3 years ago

@andrewtelnov, here is the example that reproduce issue, If you check console you will get error. Samplecode.txt