Is there a way to get a list of variables in a knockout model that are currently bound to the DOM?
Alternatively, is there a way to query a variable and find out if changing it would lead to a change in the DOM?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Using Knockout 1.3 beta, you can use
ko.dataFor(element)to return the data that would be bound against the element at that level.This means that if you had an object like:
and bound it to an element
ko.dataFor(document.getElementById("myElement"))would returnmyObjectand not just the name.Prior to 1.3, inside of a jQuery Template, you can use tmplItem to return this type of data.
There is not really a way to programmatically determine if changing an observable will specifically alter a certain element.