title: How can I Clone Chosen Plugin
body: <p>I wanted to use  <a href="http://harvesthq.github.com/chosen/" rel="nofollow noreferrer">http://harvesthq.github.com/chosen/</a> witch jquery clone function:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
      $(function(){
          var removeLink = ' &lt;a class="remove" href="#" onclick="$(this).parent().slideUp(function(){ $(this).remove() }); return false"&gt;remove&lt;/a&gt;';
          $('a.add').relCopy({ append: removeLink});
      });
  &lt;/script&gt;
  &lt;form method="post" action=""&gt;
      &lt;div id="cloner"&gt;
      &lt;p class="clone"&gt;
          &lt;script type="text/javascript"&gt;
              jQuery(document).ready(function(){
              jQuery(".chzn-select").data("placeholder","Search...").chosen();
          });
          &lt;/script&gt;
          &lt;select data-placeholder="Search..." name="actor_name[]" class="chzn-select" style="width:350px;" tabindex="2"&gt;
              &lt;option value=""&gt;&lt;/option&gt;
              &lt;?php
                  require_once '../engine/db.php';
                  $rezultat_url = mysql_query("SELECT `id`, `actor_name` FROM `actors` ORDER BY `id` DESC");
                  while($row=mysql_fetch_array($rezultat_url)){
                      $id = $row[id];
                      $aktor = $row[actor_name];
                      echo'&lt;option value="'.$id.'"&gt;'.$actor.'&lt;/option&gt;';
                  }
              ?&gt;
              &lt;/select&gt;
          &lt;input type="text" name="role_name[]" value="" /&gt;
          &lt;input type="text" name="epi_count[]" value="" /&gt;
      &lt;/p&gt;
      &lt;/div&gt;
      &lt;p&gt;&lt;a href="#" class="add" rel=".clone"&gt;Add More&lt;/a&gt;&lt;/p&gt;
      &lt;script src="chosen.jquery.js" type="text/javascript"&gt;&lt;/script&gt;
      &lt;script src="prism.js" type="text/javascript" charset="utf-8"&gt;&lt;/script&gt;
      &lt;script type="text/javascript" src="../administrator/js/reCopy.js"&gt;&lt;/script&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>This is my form clone'ing script:</p>
  
  <pre><code>/**
  * jQuery-Plugin "relCopy"
  *
  * @version: 1.1.0, 25.02.2010
  *
  * @author: Andres Vidal
  * code@andresvidal.com
  * http://www.andresvidal.com
  *
  * Instructions: Call $(selector).relCopy(options) on an element with a jQuery type selector
  * defined in the attribute "rel" tag. This defines the DOM element to copy.
  * @example: $('a.copy').relCopy({limit: 5}); // &lt;a href="example.com" class="copy" rel=".phone"&gt;Copy Phone&lt;/a&gt;
  *
  * @param: string excludeSelector - A jQuery selector used to exclude an element and its children
  * @param: integer limit - The number of allowed copies. Default: 0 is unlimited
  * @param: string append - HTML to attach at the end of each copy. Default: remove link
  * @param: string copyClass - A class to attach to each copy
  * @param: boolean clearInputs - Option to clear each copies text input fields or textarea
  *
  */
  
  (function($) {
      $.fn.relCopy = function(options) {
          var settings = jQuery.extend({
              excludeSelector: ".exclude",
              emptySelector: ".empty",
              copyClass: "copy",
              append: '',
              clearInputs: true,
              limit: 0 // 0 = unlimited
          }, options);
  
          settings.limit = parseInt(settings.limit);
          // loop each element
          this.each(function() {
  
              // set click action
              $(this).click(function(){
              var rel = $(this).attr('rel'); // rel in jquery selector format
              var counter = $(rel).length;
              // stop limit
              if (settings.limit != 0 &amp;&amp; counter &gt;= settings.limit){
                  return false;
              };
  
              var master = $(rel+":first");
              var parent = $(master).parent();
              var clone = $(master).clone(true).addClass(settings.copyClass+counter).append(settings.append);
  
              //Remove Elements with excludeSelector
              if (settings.excludeSelector){
                  $(clone).find(settings.excludeSelector).remove();
              };
  
              //Empty Elements with emptySelector
              if (settings.emptySelector){
                  $(clone).find(settings.emptySelector).empty();
              };
  
              // Increment Clone IDs
              if ( $(clone).attr('id') ){
                  var newid = $(clone).attr('id') + (counter +1);
                  $(clone).attr('id', newid);
              };
  
              // Increment Clone Children IDs
              $(clone).find('[id]').each(function(){
                  var newid = $(this).attr('id') + (counter +1);
                  $(this).attr('id', newid);
              });
  
              //Clear Inputs/Textarea
              if (settings.clearInputs){
                  $(clone).find(':input').each(function(){
                  var type = $(this).attr('type');
                      switch(type)
                      {
                          case "button":
                              break;
                          case "reset":
                              break;
                          case "submit":
                              break;
                          case "checkbox":
                              $(this).attr('checked', '');
                              break;
                          default:
                              $(this).val("");
                      }
                  });
              };
  
              $(parent).find(rel+':last').after(clone);
              return false;
  
              }); // end click action
  
          }); //end each loop
  
          return this; // return to jQuery
  
      };
  })(jQuery)
  </code></pre>
  
  <p>The problem is, that when i cloned Chosen plugin form, only the first one work and the all cloned ones shows dropdown from the firs one.</p>
  
  <p>I found similar problem with some solution here --> <a href="https://stackoverflow.com/questions/10523395/how-to-add-chosen-plugin-to-dynamically-created-cloned-css-div">How to add Chosen Plugin to dynamically created / cloned CSS div?</a></p>
  
  <p>But i have no idea how to fit it to my script. Can someone help adapt it to my script and can show me where should I copy it. </p>