JSFiddle - React, Tailwind, and code Playground
HTML
<div class="content">
<ul data-bind="foreach: workouts">
<li>
<span data-bind="text: name"> </span>
<a href="#" data-bind="click: $parent.removeWorkout">Remove</a>
<ul data-bind="foreach: exercises">
<li>
<span data-bind="text: name"> </span>
<a href="#" data-bind="click: $root.removeExercise">remove</a>
</li>
</ul>
</li>
</ul>
</div>
JavaScript
function AppViewModel() {
var self = this;
self.exercises = ko.observableArray([
{ name: "Exercise1.1" },
{ name: "Exercise1.2" },
{ name: "Exercise1.3" }
]);
self.workouts = ko.observableArray([
{name: "Workout1", exercises:self.exercises},
]);
self.removeWorkout = function() {
self.workouts.remove(this);
};
self.removeExercise = function() {
console.log(self.exercises())
self.exercises.remove(this);
};
this.editing = ko.observable(false);
this.edit = function() { this.editing(true) }
}
ko.applyBindings(new AppViewModel);