title: to have a javascript code only added once when using partial view
body: <p>i have a partial view that itself is inside a partial view. The content inside the inner most partial view can be rendered multiple times. i have a javascript code that is significant only for the innermost view. SO what happens is when the content is rendered more than once the javascript code is added twice  and event are called twice. e.g</p>
  
  <pre><code>var isDccmAndReady = '@isDccmAndReady';
  
  $(document).ready(function() {
      $(function() {
          $("input[name='ReportDate']").change(function() {
              if (isDccmAndReady) {
                  var d = new Date();
                  var currentDate = (d.getMonth() + 1) + "/" + +d.getDate() + "/" + d.getFullYear();
  
                  var dateSelected = $(this).val();
  
                  if (new Date(dateSelected) &gt; new Date(currentDate)) {
                      var answer = confirm("The contract has been already reported, are you sure you wish to continue?");
                  if (answer) {
                      return true;
                  } else {
                      $(this).val('@Model.OriginalReportDate.Value.ToShortDateString()');
                      return false;
                  }
              }
          }
          return false;
      });
  });
  </code></pre>
  
  <p>Now if the textbox is embedded twice onchange event is called two times when something changes in one of the textbox. how to circumvent this issue?</p>