In this code: http://jsfiddle.net/PDwBF/1/the google link does not work. How to restore it?
<ul data-bind="foreach: Items"> <li data-bind="click: $root.SetCurrent"> <p data-bind="text: id"></p> <div> <a href="http://google.com" target="_blank">Go to google</a> </div> </li> </ul> function ViewModel() { var self = this; self.SelectedItem = ko.observable(); self.Items = ko.observableArray([]); self.SetCurrent = function(item) { self.SelectedItem(item); }; }; var vm = new ViewModel(); ko.applyBindings(vm); vm.Items.push({id: 55}); vm.Items.push({id: 66}); vm.Items.push({id: 77});
One option is to return true; from your SetCurrent method, which will enable the default action: http://jsfiddle.net/rniemeyer/PDwBF/3/
Thanks rpn https://groups.google.com/group/knockoutjs/browse_thread/thread/6ef1081249377728
rpn
If you add return true, it works.
eg.
function ViewModel() { var self = this; self.SelectedItem = ko.observable(); self.Items = ko.observableArray([]); self.SetCurrent = function(item) { self.SelectedItem(item); return true; }; };