title: onclick in ASP.NET MVC razor CheckBoxFor not working
body: <p>I need to assign an onclick event to a CheckBoxFor in ASP.NET MVC razor, but it is never called.</p>
  
  <p>I have something like this, which does not work:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
      function setCompleteStatus() {
          alert("setCompleteStatus called");
      }
  &lt;/script&gt;
  
  @Html.CheckBoxFor(m =&gt; m.Process.IsComplete, 
                    new Dictionary&lt;string, object&gt;{
                       {"id", "p1isCompleted"}, 
                       {"onclick","setCompleteStatus()"}, 
                       {"data-role", "flipswitch"}, 
                       {"data-on-text", "complete"}, 
                       {"data-off-text", "incomplete"}, 
                       {"data-wrapper-class", "custom-size-flipswitch"}})
  </code></pre>
  
  <p>This attempt also doesn't work:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
      $("#p1isCompleted").click(
          function setCompleteStatus() {
              alert("setCompleteStatus called");
          }
      );
  &lt;/script&gt;
  </code></pre>
  
  <p>This approach leads to the <code>alert</code> being called once when the page is loaded but not when I click on the checkbox:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
      $(document).ready(
          $("#p1isCompleted").click(
              alert("setCompleteStatus called");
          )
      );
  &lt;/script&gt;
  </code></pre>
  
  <p>Because of the <code>data-</code> attributes I cannot use a dictionary like this: <code>new {@onclick, "setCompleteStatus('1')"}</code></p>
  
  <p>By the way, there are no javascript errors displayed in Firefox's console</p>