Smiling Bald Guy

Solving the world's problems using code (that honestly could use a few more unit tests).

Stupid KnockoutJS tricks #1

leave a comment »

Here’s the first in what I hope to become a long list of tips and tricks for using (and debugging) KnockoutJS:

If you want to see the state of the viewmodel that you have bound to a node in your DOM, use the following call:

ko.utils.domData.getAll($('#<<node ID>>')[0]).__ko_bindingContext__.$root
Advertisements

Written by Andy Hopper

March 22, 2012 at 9:35 am

Posted in Debugging, KnockoutJS

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: