Knockout click binding with parameters
<p>I'm trying to add an click event to my button that will send the Id, Category and Name as parameters only when the button is clicked.</p>

<pre><code>&lt;tbody data-bind="foreach: tehTab()"&gt;
    &lt;tr&gt;
       &lt;td data-bind="text: $data.Category"&gt;&lt;/td&gt;
       &lt;td data-bind="text: $data.Name"&gt;&lt;/td&gt;
       &lt;td&gt;
          &lt;button type="button" class="btn chart_btn" role="button" data-toggle="popover" data-trigger="focus" data-html="true" data-placement="right" container="body" tabindex="0" data-original-title="" title="" style="border:none; background-color:white" data-bind="attr: { id: $data.Id,'data-contentwrapper':'.chartdraw' + $data.Id},click: getLast7($data.Id, $data.Category, $data.Name) , text:$data.Value"&gt;&lt;/button&gt;
         &lt;div data-bind="css: 'chartdraw' + $data.Id" class="chartdrawetc" style="display:none"&gt;ASD&lt;/div&gt;
       &lt;/td&gt;
   &lt;/tr&gt;
&lt;/tbody&gt;
</code></pre>

<p>even if I try to change:</p>

<pre><code>click: getLast7($data.Id, $data.Category, $data.Name)
</code></pre>

<p>with</p>

<pre><code> attr: { id: $data.Id ,onclick: getLast7($data.Id, $data.Category, $data.Name)
</code></pre>

<p>it still fires the <strong>getLast7</strong> method as many times as the tehTab length. </p>

<p>What am I doing wrong?</p>