title: Returning something from a Durandal modal dialog
body: <p>I develop an asp.net solution with the Durandal template.</p>
  
  <p>I would like to use a <strong>modal dialog</strong> to choose an element in a table and return to the main viewmodel the choosen element.</p>
  
  <p>Here is what I have so far:</p>
  
  <p>On the main view I have a link <code>(changer)</code> allowing me to open the modal-dialog:</p>
  
  <p><img src="https://i.stack.imgur.com/aA1V4.png" alt="enter image description here"></p>
  
  <p>Here is the function of my viewModel called when link is clicked:</p>
  
  <pre><code>var changeSender = function (item) {
      app.showModal('viewmodels/sender');
  };
  </code></pre>
  
  <p>So I open the dialog called <code>sender</code>. </p>
  
  <p>Below is the viewModel of the <code>sender</code>:</p>
  
  <pre><code>define(function (require) {
  
      var system = require('durandal/system'),
          datacontext = require('services/datacontext');
  
      var senders = ko.observableArray();
  
      var activate = function () {
          return datacontext.getSenders(senders);
      };
  
      var buttonOk = function (dialogResult) {
          this.modal.close(dialogResult);
      }
  
      var buttonCancel = function () {
          this.modal.close();
      }
  
      var vm = {
          activate: activate,
          senders: senders,
          buttonOk: buttonOk,
          buttonCancel: buttonCancel
      };
  
      return vm;
  });
  </code></pre>
  
  <p>Below is the view of the ´sender´:</p>
  
  <pre><code>&lt;div class="messageBox autoclose" style="max-width: 500px"&gt;
      &lt;div class="modal-header"&gt;
          &lt;h3&gt;Expéditeur&lt;/h3&gt;
      &lt;/div&gt;
      &lt;div class="modal-body"&gt;
            &lt;table class=""&gt;
              &lt;thead&gt;
                  &lt;tr&gt;
                      &lt;th&gt;&lt;/th&gt;
                      &lt;th&gt;Name&lt;/th&gt;
                      &lt;th&gt;Street&lt;/th&gt;
                      &lt;th&gt;City&lt;/th&gt;
                  &lt;/tr&gt;
              &lt;/thead&gt;
  
              &lt;tbody data-bind="foreach: senders"&gt;
                  &lt;tr data-bind="attr: {'data_id':id}"&gt;
                      &lt;td&gt;&lt;input type="radio" name="isSelected" data-bind="checked: isSelected" /&gt;&lt;/td&gt;
                      &lt;td data-bind="text: name"&gt;&lt;/td&gt;
                      &lt;td data-bind="text: street"&gt;&lt;/td&gt;
                      &lt;td data-bind="text: city"&gt;&lt;/td&gt;
                  &lt;/tr&gt;
              &lt;/tbody&gt;
          &lt;/table&gt;
      &lt;/div&gt;
      &lt;div class="modal-footer"&gt;
          &lt;button class="btn btn-primary" data-bind="click: buttonOk"&gt;Ok&lt;/button&gt;
          &lt;button class="btn" data-bind="click: buttonCancel"&gt;Cancel&lt;/button&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/PHZfH.png" alt="enter image description here"></p>
  
  <p><strong>My problem</strong> is I don't know how to identify the selected radio button and return it to the main view.</p>
  
  <p>Any help is greathly appreciated.</p>
  
  <p>Thanks.</p>