title: Knockout Event Fires twice
body: <p>in my MVC application im creating multiple Dropdowns by following:</p>
  
  <pre><code>&lt;select data-bind="options: findGroup(1).items(),
                          optionsText: 'country',
                          optionsValue: 'id',
                          value: selectedItem(1),
                          event: { change: selectionChange }"&gt;&lt;/select&gt;
  </code></pre>
  
  <p>the  findgroup(x) and the selectedItem(x) are global functions in my ViewModel while those are for all the dropdowns the same.</p>
  
  <p>the selectedItem(x) should return the currently selected Option of the dropdown. selectedItem(x) is a function to return a computed knockout observable.</p>
  
  <p>Now im facing the Problem that the selectionChange Event is fired twice. See this fiddle for an example: <a href="http://jsfiddle.net/LGveR/20/" rel="nofollow">http://jsfiddle.net/LGveR/20/</a> 
  In this example, if you Change the value of the Dropdown box, you can see that the selectionCahnge Event is fired twice.</p>
  
  <p>When i leave the value: selectedItem(x) out  (and thus no computed function in the code) it doesnt: see: <a href="http://jsfiddle.net/LGveR/21/" rel="nofollow">http://jsfiddle.net/LGveR/21/</a></p>
  
  <p>I think that second time the Event is being fired Comes from the fact that in the computed function selectedItem(x) the observable </p>
  
  <pre><code>grp.selectedItem(grp.findItemByValue(value));
  </code></pre>
  
  <p>is setted.
  How to prevent that the Setting of this observable leads to a "Change" Event ?</p>
  
  <p>TIA,
  Paul</p>
  
  <p>HTML:</p>
  
  <pre><code>   &lt;select data-bind="options: findGroup(1).items(),
                          optionsText: 'country',
                          optionsValue: 'id',
                          value: selectedItem(1),
                          event: { change: selectionChange }"&gt;&lt;/select&gt; &lt;span data-bind="text: 'aantal: ' + findGroup(1).items().length"&gt;&lt;/span&gt;
  
  &lt;br /&gt; &lt;span data-bind="text: 'Group Selected Country: ' + findGroup(1).selectedItem().country"&gt;&lt;/span&gt;
  
  &lt;br /&gt; &lt;span data-bind="text: 'Computed Selected Country: ' + selectedItem(1)().country"&gt;&lt;/span&gt;
  
  &lt;br /&gt; &lt;span data-bind="text: 'after select: ' + counter()"&gt;&lt;/span&gt;
  
  &lt;br /&gt;
  </code></pre>
  
  <p>Javascript:</p>
  
  <pre><code> var group = function (id) {
       this.id = id;
       this.items = ko.observableArray() || {};
       this.selectedItem = ko.observable();
       this.addItem = function (data) {
           this.items.push(data);
       };
       this.findItemByValue = function (id) {
           return ko.utils.arrayFirst(this.items(), function (item) {
               return item.id === id;
           });
       }
   };
  
  
   var grpItem = function (id, country) {
       this.id = id;
       this.country = country;
   };
  
  
  
   var ViewModel = function () {
       this.groups = ko.observableArray() || {};
  
  
       this.counter = ko.observable(0);
       this.selectionChange = function (data, event, selector, item) {
  
           this.counter(this.counter() + 1);
       };
  
       this.addGrp = function (data) {
           this.groups.push(data);
       };
  
       this.findGroup = function (groupId) {
           var ret = ko.utils.arrayFirst(this.groups(), function (c) {
               return c.id === groupId;
           });
           return ret;
       };
  
       this.selectedItem = function (groupId) {
           var grp = this.findGroup(groupId);
           return ko.computed({
               read: function () {
                   return this.findGroup(groupId).selectedItem();
               },
               write: function (value) {
                   grp.selectedItem(grp.findItemByValue(value));
               }
           }, this);
       };
   };
  
   var vm = new ViewModel();
   var p = new group(1);
   var a = new grpItem(1, 'holland');
   var b = new grpItem(2, 'germany');
   var c = new grpItem(3, 'brasil');
   p.addItem(a);
   p.addItem(b);
   p.addItem(c);
  
   vm.addGrp(p);
  
  
   ko.applyBindings(vm);
  </code></pre>