JQuery & Objects, trying to make a lightweight widget
<p>Trying to make a make generic select "control" that I can dynamically add elements to, but I am having trouble getting functions to work right.</p>

<p>This is what I started with.</p>

<pre><code>$select = $("&lt;select&gt;&lt;/select&gt;");
$select.addOption = function(value,text){
$(this).append($("&lt;option&gt;&lt;/option&gt;").val(value).text(text));
  };
</code></pre>

<p>This worked fine alone but anytime <code>$select</code> is <code>.clone(true)</code>'ed the <code>addOption()</code> function is lost.  </p>

<p>This is my object approach but still the function does not work.</p>

<pre><code>function $selectX() {
        return $("&lt;select&gt;&lt;/select&gt;");
        }

$selectX.prototype.addOption() = function(value,text){
         $(this).append($("&lt;option&gt;&lt;/option&gt;").val(value).text(text));
      };
</code></pre>

<p>Hack solution is to add the function manually after creation:</p>

<pre><code>$nameSelect= new $selectX;
$nameSelect.addOption = function(value,text){
     $(this).append($("&lt;option&gt;&lt;/option&gt;").val(value).text(text));
 };
</code></pre>

<p>Am I barking up the wrong tree?</p>
