title: downloading a file on click in knockout.js
body: <p><strong>html</strong></p>
  
  <pre><code>&lt;tbody data-bind="foreach: arrayList"&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;a href="#" data-bind="click: $parent.downloadLastFile"&gt;Download&lt;/a&gt;&lt;/td&gt;
      &lt;/tr&gt;
  &lt;/tbody&gt;
  </code></pre>
  
  <p><strong>javascript</strong></p>
  
  <pre><code>    function ItemViewModel(item){
      if(!$.isEmptyObject(item)){
        var self = this;
        self.lastFile = ko.observable(item.file_name);    
  
        self.downloadLastFile = function(row) {
           console.log(row.lastFile());
           var link = document.createElement('a');
           link.href = data;
           link.download = row.lastFile();
           document.body.appendChild(link);
           link.click();
          }
       }
     }
  function MainViewModel() {
      var self = this;
      self.arrayList= ko.observableArray();
  }
  dataModel = new MainViewModel();
  ko.applyBindings(dataModel);
  </code></pre>
  
  <p>I am trying to download a file on clicking. This piece of code is not working. Can someone check?</p>