title: How to check values in Dynamic Text Editor got changed or not?
body: <p>I have a text editor that is created in runtime-dynamically with dynamic id's.</p>
  <p>Before close the window , I am trying to check whether anything changed in that editor or not.</p>
  <p>I tried with different events such as onblur, onfocusout, onkeypress etc..</p>
  <p>Here is my code:</p>
  <pre><code>   &lt;table  class=&quot;table table-bordered border-collapse&quot;&gt;
        &lt;thead &gt;
                                  &lt;tr&gt;
                                      &lt;th&gt;Process&lt;/th&gt;
                                      &lt;th&gt;Edited Value&lt;/th&gt;
                                  &lt;/tr&gt;
                              &lt;/thead&gt;
                                &lt;tbody&gt;
                                 @if (Model.Names.Count != 0)
                                  {                                
                                      for (int i = 0; i &lt; Model.Details.Count(); i++)
                                      {                                    
                                           TxtId = &quot;txtProcess&quot; + i;
                                           hdnId = &quot;hdntxtProcess&quot; + i;
                                           
                                  &lt;tr class=&quot;GridRow&quot;&gt;
      
                                          &lt;td &gt;&lt;div class=&quot;form-control-stack required&quot;&gt;
                                              @{var labelText = Name; }
                                              @Html.Label(&quot;lbl&quot; + Model.Details[i].ProcessName, labelText, new { @id = Model.Details[i].Name })
      &lt;/div&gt;
                                          &lt;/td&gt;
                                          &lt;td &gt;                               
                      &lt;textarea  id=&quot;@TxtId&quot; rows=&quot;8&quot;  name=&quot;@TxtId&quot; class=&quot;form-control ckeditor&quot; onblur=&quot;CheckData(@TxtId)&quot;  &gt;  
  //here i tried with different functions onchange,on input etc...
                      @Html.Raw(System.Web.HttpUtility.HtmlDecode(Model.Details[i].Details))
                  &lt;/textarea&gt;
                                            
                                              &lt;input type=&quot;hidden&quot; id=&quot;@hdnId&quot; value=&quot;@Model.Details[i].ID&quot;/&gt;
                                                                                     
                                          &lt;/td&gt;
                                &lt;/tbody&gt; 
        
        &lt;/table&gt;
  </code></pre>
   
  <p>Script as follows:</p>
  <pre><code> function CheckData(id) {
          $(&quot;#&quot; + id).on(&quot;focusout&quot;, function () {
              document.getElementById(&quot;hdn_data&quot;).value = &quot;1&quot;;
          });
      }
  
      function RefreshParent() {
           if (document.getElementById(&quot;hdn_data&quot;).value == &quot;1&quot;) {
          var confirmationMessage = 'changes you did may lost. Are you sure want to leave?';
  
          return confirmationMessage;
  
      }
  }
    
      window.onbeforeunload = RefreshParent;
  </code></pre>
  <p>other ways i tried :</p>
  <pre><code>var rowcount=0;
   $(document).ready(function () {
      $(&quot;tr.GridRow&quot;).each(function () {       
  
          CKEDITOR.instances[&quot;txtProcess&quot; + RowCount].on('change', function () {
                  alert(&quot;testing&quot;);
                  $(&quot;#txtProcess&quot; + RowCount).on(&quot;focusout&quot;, function () {
                      document.getElementById(&quot;hdn_data&quot;).value = &quot;1&quot;;
                  });
              });
          });
  
     
      });
  </code></pre>
  <p>What I am exactly trying to do is, when i close the window,if anything changed, I need to check with an alert message whether to continue or not..</p>
  <p>How to do it?</p>
  <p>Kindly help.</p>