Problem reading through ajax file

50 views
Skip to first unread message

David Williams

unread,
Jul 18, 2016, 1:15:58 PM7/18/16
to KnockoutJS
Hello, I'm struggling to display a table based on the contents of an ajax call. This is quite standard code for me but what is new (for reasons I cannot control) is that the data is now inside $values. What should my html look like?

This is the ajax response - 














and this is the html I'm using -

                <table>
                    <thead>
                        <tr>
                            <th></th>
                            <th>Name</th>
                            <th>Reference</th>
                            <th>Date of Birth</th>
                            <th>Status</th>
                        </tr>
                    </thead>
                    <div data-bind="with: data">
                        <tbody data-bind="foreach: $values">
                            <tr>
                                <td><a href="#" data-bind="click: function () { $root.viewContactDetails(Id) }"><i class="icon-info-sign blue-icon"></i>&nbsp;Detail</a></td>
                                <td data-bind="text: FullName"></td>
                                <td data-bind="text: ExternalKey"></td>
                                <td data-bind="text: DateOfBirthString"></td>
                                <td data-bind="text: Status"></td>
                            </tr>
                        </tbody>
                    </div>
                </table>

Which give the following error -

Uncaught ReferenceError: Unable to process binding "with: function (){return pagedResults }"
Message: Unable to process binding "foreach: function (){return $values }"
Message: $values is not defined

Thanks in anticipation.

Daniel Weipert

unread,
Jul 19, 2016, 6:24:12 AM7/19/16
to KnockoutJS
Based on this stackoverflow question:

http://stackoverflow.com/questions/23746342/using-knockout-with-property-names-containing-or-other-special-characters

I guess you'd do something like this:
 <tbody data-bind="foreach: $data[ '$values' ]">

David Williams

unread,
Jul 19, 2016, 9:13:02 AM7/19/16
to KnockoutJS
Thanks, that gave my googling a bit of a boost.

That doesn't give any errors regardless of what I add in the brackets but doesn't 'find' the $values either.


Gunnar Liljas

unread,
Jul 19, 2016, 10:32:30 AM7/19/16
to knock...@googlegroups.com
In your JSON example "Data" is capitalized, but in the "with:data" it's not.

2016-07-19 15:13 GMT+02:00 David Williams <david25...@gmail.com>:
Thanks, that gave my googling a bit of a boost.

That doesn't give any errors regardless of what I add in the brackets but doesn't 'find' the $values either.


--
You received this message because you are subscribed to the Google Groups "KnockoutJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to knockoutjs+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

David Williams

unread,
Jul 21, 2016, 12:01:23 PM7/21/16
to KnockoutJS
I've tried that, no joy. Not to worry,it's looking like we won't need this anymore anyway.

Thanks for all your help.
Reply all
Reply to author
Forward
0 new messages