Click here to Skip to main content
15,886,963 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
HTML
<table>
            <tbody data-bind="foreach: showinTable">
                <tr>
                    <td>
                        <input data-bind="value: proudctID" />
                    </td>
                    <td>
                        <input data-bind="value: proudctName" />
                    </td>
                </tr>
            </tbody>
        </table>


JavaScript
$.getJSON("/api/Product/GetProducts", null, function (data, status, jqxhr) {
            //alert(data.products)
            self.showinTable = ko.mapping.fromJSON(data);
            ko.applyBindings(new AppViewModel());
        });


Uncaught Error: Unable to parse bindings.
Message: ReferenceError: showinTableis not defined;
Bindings value: value: foreach


json data

JavaScript
{"products":[{"proudctID":1,"proudctName":"Product  One"},{"proudctID":2,"proudctName":"Product  Two"},{"proudctID":3,"proudctName":"Product  Three"},{"proudctID":4,"proudctName":"Product  Four"},{"proudctID":5,"proudctName":"Product  Five"}]}
Posted
Updated 11-Sep-13 4:15am
v3
Comments
Joezer BH 11-Sep-13 10:23am    
looks like the <tbody data-bind="foreach: showinTable"> bind is not working and the showinTable is not defined properly...
Faisalabadians 11-Sep-13 10:30am    
It is bind properly, the issue is json, when I change it to [{productID:1,productName:"one"},{productID:1,productName:"one"},{productID:1,productName:"one"}] then every thing works fine.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900