JSFiddle - React, Tailwind, and code Playground

by RobertSudwarts

HTML

<script src="http://knockoutjs.com/downloads/knockout-3.0.0.js"></script>
<ul data-bind="foreach: places">
    <li> <span data-bind="text: $data"></span>

        <button data-bind="click: $parent.removePlace">Remove</button>
    </li>
</ul>

JavaScript

function MyViewModel() {
     var self = this;
     self.places = ko.observableArray(['London', 'Paris', 'Sydney','Tokyo']);

     // The current item will be passed as the first parameter, so we know which place to remove
     self.removePlace = function (place) {
         self.places.remove(place)
     }
 }
 ko.applyBindings(new MyViewModel());