If I have 2 different JS objects on a page, both having a property called “name”, and I do:
<span data-bind="text:name"></span>
How can I tell Knockout which object to bind to?
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.
In general you are supposed to have one view model that you apply all bindings to:
So you need to decide which of your objects you want to make a view model. If you need both, you can make them subobjects of your model:
Html: