<ul multiple="multiple">
<!-- ko foreach: list -->
<li data-bind="event: {mouseover: $parent.showDelete, mouseout: $parent.hideDelete}">
<div >
<span style="vertical-align: center; height: 25px;"
data-bind="text: name"></span>
<a data-bind="visible: $data.deleteVisible" href="#">Remove</a>
</div>
</li>
<!-- /ko -->
</ul>
<p>
<button data-bind="click: addItem">Add</button>
<button data-bind="click: removeItem">Remove</button>
</p>$(function() {
var data = [ {name: "Bob"}, {name: "Joe"}, {name: "John"} ];
var viewModel = {
list: ko.observableArray(data),
deleteVisible: ko.observable(false),
addItem: function() {
this.list.push({name: "Steve"});
},
removeItem: function() {
this.list.pop();
} ,
showDelete: function() {
this.deleteVisible(true);
},
hideDelete: function() {
this.deleteVisible(false);
}
};
ko.applyBindings(viewModel);
}); It's looking for deleteVisible on the item, but it belongs to the viewModel/parent
--
You received this message because you are subscribed to the Google Groups "KnockoutJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to knockoutjs+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.