title: Dynamically add option to chosen select multiple JQuery plugin
body: <p>I want to add the text that a user inputs in the text field of a chosen select multiple input as an option, and automatically select it, all of this when the option doesn't exists, if the option exists, then I would like to select it. So far I have manage to do this:</p>
  <pre><code>Chosen.prototype.add_text_as_option = function () {
      $('#id_select').append(
          $('&lt;option&gt;')
                  .html(this.search_field.val())
                  .attr('selected', 'selected')
                  .attr('value', 0)
      );
      $('#id_select').trigger(&quot;liszt:updated&quot;);
      return false;
  };
  </code></pre>
  <p>I call this function whenever the users presses enter while the input field is in focus within the <code>keydown_check</code> function.</p>
  <p>I have two problems:</p>
  <ul>
  <li>Top priority, when the user presses enter and has typed a substring of an option, the option won't get selected, but the substring text will be added and selected. Not what I want.</li>
  </ul>
  <p>For instance: If I have the option &quot;foo&quot;, and start typing &quot;fo&quot;, chosen will mark the first
  option as candidate (&quot;foo&quot;), so if I press enter, it should be selected, but instead, what happens is that &quot;fo&quot; is added as an option and selected, when I actually wanted to select &quot;foo&quot;.</p>
  <p>If I select &quot;foo&quot; with a click, then everything works fine. The option chosen marks is selected and the substring text is taken as part of the option.</p>
  <p>How can I add a non existent option to chosen, without loosing all the original functionality?</p>
  <ul>
  <li><p>How can I access the select multiple field I initilized whith chosen inside the chosen plugin? As you can see in the code above, the id of the select multiple field is hardcoded. I want to do this to be able to refresh the select when the user adds a new option.</p>
  </li>
  <li><p>The functionality that I'm looking for is very similar to the skills widget of <a href="http://linkedin.com" rel="nofollow noreferrer">linkedin</a></p>
  </li>
  </ul>