1

I'm trying to link a list of my own creation up with KoSP. I created the list "Employees" which was used in the tutorial and got it to work perfectly, it consistently displays the Employee list and throws no errors. However it refuses to display my own list. The list has 7-8 columns, but I'm just trying to get it to display anything at all and not throw an error. The error thrown is:

Uncaught ReferenceError: Unable to process binding "template: function (){return { name:'Zac',foreach:ZacTest} }"
Message: ZacTest is not defined

I've browsed to the list at http://mysite//_vti_bin/listdata.svc/ZacTest and it displays fine in browser, there are no problems with that. Here is the code for the page:

<div class="row content">
         <table width="100%"  id="employeeTable" class="container">
                 <thead>
                         <tr>
                                 <th><h1>Employee Name</h1></th>
                                 <th><h1>Skill Set</h1></th>
                                 <th><h1>Created Date</h1></th>
                                 <th><h1>ID</h1></th>
                         </tr>
                 </thead>
                 <tbody data-bind="template: { name: 'Emp', foreach: Employees }" />
         </table>
 </div>
<p>&nbsp;</p>
 <div id="adminList" class="row content">
    <h2>Admin Table</h2>
    <table id="adminTable" class="container">
        <thead>
            <tr>
                <th><h1>Document Modified</h1></th>
            </tr>
         </thead>
        <tbody data-bind="template: { name: 'Zac', foreach: ZacTest }" />
    </table>
</div>
<script type="text/html" id="Emp">
         <tr>
                 <td data-bind="text:Title"></td>
                 <td data-bind="spChoice:Skills"></td>
                 <td data-bind="spDate:Date,dataFormat:'MMMM Do YYYY, h:mm:ss A'"></td>
                 <td data-bind="spUser:ModifiedBy"></td>
         </tr>
 </script>
 <script type="text/html" id="Zac">
         <tr>
                 <td data-bind="text:Modified"></td>
         </tr>
 </script>
 <script type="text/javascript">
     function ZacTestModal() {
            var self = this;
            self.ZacTest = ko.observableArray([]);
            $.getJSON(_spPageContextInfo.webAbsoluteUrl + "/_vti_bin/listdata.svc/ZacTest",
                function (data) {
                    if (data.d.results) {
                        self.ZacTest(ko.toJS(data.d.results));
                    }
                });
    }
     function EmployeeModal() {
         var self = this;
         self.Employees = ko.observableArray([]);
         $.getJSON(_spPageContextInfo.webAbsoluteUrl + "/_vti_bin/listdata.svc/Employees?$expand=Skills,ModifiedBy",
             function (data) {
                 if (data.d.results) {
                     self.Employees(ko.toJS(data.d.results));
                 }
             }
             );
     }
    $(document).ready(function () {
        ko.applyBindings(new EmployeeModal());
        ko.applyBindings(new ClearanceModal());
    });
</script>

Please let me know if you have any ideas, I'm hoping it's a typo or something simple that I'm overlooking.

1

You should may be use new ZacTestModal() instead of new ClearanceModal() in your javascript ko.applyBindings

  • My apologies, I changed the name of the function in my paste. It still gives me the same error when the function is called correctly. – Katori May 18 '15 at 12:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.