I have an observable array that holds a list of people and a table that displays their first name, with a select button for each. When the user clicks the select button I’d like another element on screen to display the person’s full name. Is there a way to get it so that if a person is removed from the array, it also removes the element displaying their full name?
Edit: I can achieve this by putting self.SelectedPerson(false); in the remove function, but is there a better way of doing it?
2nd Edit: Changed the jsFiddle
One useful thing here is that in the click method in a
foreachloop you get the current data item sent to the function, which means that you can set theSelectedAccountobservable to the item sent to the function.Check this updated jsFiddle: http://jsfiddle.net/jCkuY/1/
And for the remove function you can either set the selectedAccount to an empty
Accountobject or even to null, but then you’ll need to use an if binding perhaps.