Troublshooting uncaught exception: [object Object]

78 views
Skip to first unread message

jjf...@gmail.com

unread,
Jun 18, 2013, 9:56:27 AM6/18/13
to knock...@googlegroups.com
Hello,
I'm getting "uncaught exception: [object Object]" error while trying to adapt jsfiddle code http://jsfiddle.net/jjfrick/wDwme/ to my app.
How can I go about troubleshooting this can of error?
I changed:
    employees: ko.observableArray([
       
new employee(201, "Gerald", "574-234-1234", 101),
       
new employee(202, "Andy", "574-234-2345", 102),
       
new employee(203, "Ed", "574-234-3456", 102),
       
new employee(204, "Bill", "574-234-4567", 103),
       
new employee(205, "Frank", "574-234-5678", 103),
       
new employee(206, "Chris", "574-234-6789", 104),
       
new employee(207, "Dave", "574-234-7891", 104),
   
]),
to...
        loadEmployees: function () {
           
OData.read(_serviceURL + "/HRdata?$filter=Status eq 'A' and length(HomeDeptCode) eq 6&$orderby=LastName",
           
function (data) {
                viewModel
.employees.removeAll();
                $
.each(data.results, function (index, item) {
                    viewModel
.employees.push(ko.mapping.fromJS(item));
               
});
           
});
       
},
the above code alone does not result in an error, but when I change:
ko.applyBindings(viewModel);
to

ko.applyBindings(viewModel);
viewModel.loadEmployees();
I get the error.
Thansk, Jeff


parwej ahamad

unread,
Jun 18, 2013, 10:20:52 AM6/18/13
to knock...@googlegroups.com
Can you suggest us on which line you are getting error? 
Are you sure data object is populating through the service?
Return data is having the same format as you are binding?


--
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/groups/opt_out.
 
 

Ryan Rahlf

unread,
Jun 18, 2013, 12:27:23 PM6/18/13
to knock...@googlegroups.com
JJ, this is certainly an issue inside your "loadEmployees" function.  

Does OData exist?  Does _serviceURL exist?  Is it accessible?  Is the ko.mapping script included and ko.mapping exists?  These are the things you'll need to verify before you look into knockout issues.  You may be able to get some of these working in your fiddle using external resources, but it's probably quicker to add a few quick checks in your loadEmployees function in your development code.

-Ryan Rahlf
____________________
@Ryanthem
Reply all
Reply to author
Forward
0 new messages