paradox
unread,Jul 4, 2011, 8:55:58 PM7/4/11Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to KnockoutJS
Hey,
I'm new to knockout.js, but quite like it. However, as my view model
gets more and more complex, I'm finding it increasingly difficult to
debug and inspect. At the moment I am having problems with loading a
view model from JSON and figuring out what is happening to my
observables, dependent observables, etc. I want to get some feedback
from the experts, on how they inspect and debug their view model.
I started off with log4javascript, and just using ko.toJSON(), like
so:
log.debug("View model: " + ko.toJSON(viewModel));
This works for a tiny view model, but the output is unformatted, so it
soon gets hard to read.
Firebug, has a very nice console API, which allows you to inspect
objects. Currently I am doing:
console.group("Dumping view model");
console.dir(ko.toJS(viewModel));
console.groupEnd();
It displays a tree of the view model, which you can click through and
inspect.
This works well. However, because we are using toJS, its impossible
to see what are observables, what are straight objects, etc. Doing
console.dir(viewModel); just shows a whole bunch of functions, which
is not very helpful.
What are other people using? How do you inspect and debug problems in
the view model?