title: how to add a tinymce editor to a dynamically added textarea?
body: <p>Guys recently i finished a infinite scroll to one of my projects using jquery, php and mysql. After creating that i face the problem of tinymce editor not binding to the dynamically generated textarea. What should i do?
  here is the code for tinymce editor:</p>
  
  <pre><code>tinymce.init({
      menubar:false,
      forced_root_block : "",
      selector: "textarea#wall_edit_1",
       entities : '160,nbsp,162,cent,8364,euro,163,pound',
      theme: "modern",
      resize: false,
      height: 200,
      plugins: [
           " autolink link image preview hr anchor pagebreak spellchecker",
           "searchreplace wordcount visualblocks visualchars insertdatetime media nonbreaking",
           "save table contextmenu directionality emoticons paste textcolor"
     ],
     content_css: "css/content.css",
     toolbar: "insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | l      ink image | print preview media fullpage |  emoticons", 
     style_formats: [
          {title: 'Bold text', inline: 'b'},
        //  {title: 'Red text', inline: 'span', styles: {color: '#ff0000'}},
          {title: 'Header', block: 'h1'},
          {title: 'Example 1', inline: 'span', classes: 'example1'},
          {title: 'Example 2', inline: 'span', classes: 'example2'},
          {title: 'Table styles'},
          {title: 'Table row 1', selector: 'tr', classes: 'tablerow1'}
      ]
      });
  </code></pre>
  
  <p>here is the php code that dynamically generates the textarea while using the infinite scroll feature in jquery:</p>
  
  <pre><code>if ($author==$_SESSION['uname'] || $account_name==$_SESSION['uname']) {
                  $statusdeletebutton='&lt;li&gt;'
                             . '&lt;a  type="'.$updateid.'" class="btn delete_4_session hidden_text_delete_'.$updateid.' glyphicon glyphicon-trash delete_status_btn" title="Delete this status and its replies"&gt;Remove&lt;/a&gt;&lt;/li&gt;';
                  $edit_btn='&lt;li&gt;'
                          . '&lt;a attr="'.$updateid.'" type="'.$updateid.'" class="btn edit_4_session hidden_text_edit glyphicon glyphicon-pencil" title="Edit this status" &gt;Edit&lt;/a&gt;&lt;/li&gt;';
                  $statusui_edit="&lt;div type='".$updateid."' class='hidden_edit_4_session session_editor".$updateid." jumbotron'&gt;"
              . "&lt;a type='".$updateid."' class='btn pull-right close_edit' title='Close without editing'&gt;Close X&lt;/a&gt;"
              . "&lt;input type='text' class='form-control title_s_edit title_s_".$updateid."' name='status_title' value='".html_entity_decode($title)."' placeholder='Title' &gt;"
              . "&lt;span&gt;&amp;nbsp;&lt;/span&gt;"
              . "&lt;textarea id='wall_edit_1' type='".$updateid."' rows='5' cols='50'  class='session_edit text_value_".$updateid."' wrap='hard' placeholder='whats up ".$session_uname."'&gt;
               ".html_entity_decode($data1)."&lt;/textarea&gt;&lt;br&gt;"
              . "&lt;button style='float:right;' value='".$updateid."' type='a' class='btn btn-warning btn btn-large btn-lg post-s-edit'&gt;Update&lt;/button&gt;&lt;/div&gt;" ;
  
                  }else{
                      $statusdeletebutton="";
                      $edit_btn="&lt;li class='posted'&gt;You are not the owner of this Post&lt;/li&gt;";
                      $statusui_edit="";
                  }
  
         echo $statusui_edit.''. $hidden_text.'&lt;div attr="'.$updateid.'" type="'.$updateid.'" class="statusboxes status_'.$updateid.'  jumbotron"&gt;'
                          . '&lt;h3 class="pull-left title"&gt;'
                          . '&lt;div id="'.$updateid.'" class="title_s_2copy posted" value="'.html_entity_decode($title).'"&gt;'.html_entity_decode($title).'&lt;/div&gt;&lt;/h3&gt;'
                          . '&lt;span class="pull-right"&gt;'
                          . '&lt;div class="dropdown"&gt;'
                          . '&lt;button type="button" class="btn btn-danger dropdown-toggle" data-toggle="dropdown"  &gt;'
                          . '&lt;span class="glyphicon glyphicon-edit"&gt;&lt;/span&gt;&lt;/button&gt;'
                          . '&lt;ul class="dropdown-menu"&gt;'
                           .$edit_btn .' '. $statusdeletebutton .'&lt;/ul&gt;&lt;/div&gt;&lt;/span&gt;&lt;br&gt;&lt;hr&gt;'
                          . '&lt;legend&gt;&lt;span style="font-size: 13.5px;" class=" data_s_2copy" type="'.$updateid.'" &gt;'
                          . html_entity_decode($data1).'&lt;/span&gt;&lt;/legend&gt;&lt;b class="posted"&gt;&lt;small&gt;Posted by:-  &lt;a href="home.php?u='.$author.'"&gt;&lt;img src="'.$feed_pic.'" height="20px" width="20px"&gt; '.$author.   '&lt;/a&gt;   '.$datemade.'&lt;/small&gt;&lt;/b&gt;'
                          . '&lt;br&gt;&lt;legend&gt;'.$like.' | '.$unlike. ' | '.$share_button.'&lt;h4&gt;&lt;a id="'.$updateid.'" class="btn collap-btn"&gt;Comments&lt;/a&gt;&lt;/h4&gt;&lt;/legend&gt;';
  </code></pre>
  
  <p>here is the place where i init it in jquery @rob:</p>
  
  <pre><code>    $(document).on("click",".hidden_text_edit",function(){
      var id=$(this).attr("type");
  
      $(".session_editor"+id).removeClass("hide");
      $(".session_editor"+id).show(function(){
          tinymce.init({
      menubar:false,
      forced_root_block : "",
      selector: "textarea#wall_edit_1",
       entities : '160,nbsp,162,cent,8364,euro,163,pound',
      theme: "modern",
      resize: false,
      height: 200,
      plugins: [
           " autolink link image preview hr anchor pagebreak spellchecker",
           "searchreplace wordcount visualblocks visualchars insertdatetime media nonbreaking",
           "save table contextmenu directionality emoticons paste textcolor"
     ],
     content_css: "css/content.css",
     toolbar: "insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | l      ink image | print preview media fullpage |  emoticons", 
     style_formats: [
          {title: 'Bold text', inline: 'b'},
        //  {title: 'Red text', inline: 'span', styles: {color: '#ff0000'}},
          {title: 'Header', block: 'h1'},
          {title: 'Example 1', inline: 'span', classes: 'example1'},
          {title: 'Example 2', inline: 'span', classes: 'example2'},
          {title: 'Table styles'},
          {title: 'Table row 1', selector: 'tr', classes: 'tablerow1'}
      ]
      });
      });
  
      $(".status_"+id).hide();
  
      });
  </code></pre>