0

When I use an array of custom jaydata objects the result is bizarre.

var arr = [];
arr.push(new Northwind.Employee());
arr.push(new Northwind.Employee());

var newarr = ko.mapping.fromJS(arr);

If the debug is observed, the variable newarr looks like an observable array. If you try to unwrap to expose the underlying array:

newarr()

you get "An unspecified error has occured."

To make things weirder, if you go a step further:

newarr()[0]

you are blessed with the first element of the array. Knockout bindings behave as expected, I just cannot perform array operations (length, push, pop) and that is critical.

I really need the mapping.fromJS as I'm dealing with large trees of objects and I'm baffled regarding how to proceed from here. Mapping behaves properly with POJO objects, but jaydata is a crucial piece to my puzzle as well. Can anyone help show me what I'm doing wrong?

Here is a fiddle with what I'm discussing. I can't get it to work but it at least gives a full context. http://jsfiddle.net/jpirok/AAEuM/

Thanks for your help!

Jpirok
  • 124
  • 7
  • 1
    There's actually a number of things wrong with your fiddle totally unrelated and doesn't demonstrate the problem you're seeing. Is your actual code like this? Getting past the errors, it then throws "datajs is required" errors. Please fix your fiddle. – Jeff Mercado Dec 11 '12 at 16:27
  • I'm trying to give a concise replication of the issue, this is not my actual code. My javascript is typically generated for me through Typescript. I'm working on the jsfiddle now. – Jpirok Dec 11 '12 at 17:03
  • After figuring out what was wrong with my fiddle, I am not seeing the same behavior there as in my code. I'm going to dig back in my code and attempt to sort out what is different in the examples. I'll report back on this later today. Thanks for everyone's help! – Jpirok Dec 11 '12 at 17:59

2 Answers2

1

This ended up being a non-issue. Thanks for the help and sorry it took me awhile to close this!

Jpirok
  • 124
  • 7
0

I work for JayData. JayData support knockoutjs, we have lots of examples here: http://jaydata.org/examples/index.html

Have you included jaydatamodules/knockout.js?

Gabor Dolla
  • 2,680
  • 4
  • 14
  • 13