Awarious OfficePortal - HRMS Application

knockout exception cannot read property fromjs of undefined

0 votes
asked Jul 23, 2014 in javascript library by anonymous

I am using knockout.js in my webpage. I have written simple code given below to load viewmodel from a javascript object. But it thorw exception as

Uncaught TypeError: Cannot read property 'fromJS' of undefined

var dataModel = [{ id : 0, positionid : 0,  name: ""}]

mapping = {};
var viewModel = ko.mapping.fromJS(dataModel);

I just followed the same thing given in knockoutjs website.My dataModel object is created successfully and I see the object data. Still the error says undefined.

knockout exception - Cannot read property fromJS of undefined

Note: I have loaded, JQuery.js, knockout.js.


1 Answer

+1 vote
answered Jul 23, 2014 by shilla

Everything looks good except one thing that, knockout.mapping.js file, that does not come by default with knockout.js, is missing from your list (I am not sure whether you forget to mention here). I don't think there are any other issue. If you have already include knockout.mapping.js, then you may need to make sure the order of the js files. Sometime, that may cause issues too.

Your answer


Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please log in or register.
site design / logo / content © 2013 - 2019