title: How to get all the values in a Select2 dropdown?
body: <p>How can we get all the elements that are in the jQuery Select2 dropdown plugin.</p>
  
  <p>I have applied Select2 to a input type = hidden, and then populated it using Ajax.</p>
  
  <p>Now at one instance I need to get all the values that are appearing in the dropdown.</p>
  
  <p>Here is a input field.</p>
  
  <pre><code>&lt;input type="hidden" id="individualsfront" name="individualsfront" style="width:240px" value="" data-spy="scroll" required /&gt;
  </code></pre>
  
  <p>and to this input field I have applied this </p>
  
  <pre><code>$("#individualsfront").select2({
      multiple: true,
      query: function (query){
          var data = {results: []};
          $.each(yuyu, function(){
              if(query.term.length == 0 || this.text.toUpperCase().indexOf(query.term.toUpperCase()) &gt;= 0 ){
                  data.results.push({id: this.id, text: this.text });
              }
          });
          query.callback(data);
      }
  });
  </code></pre>
  
  <p>The yuyu is a json coming from some AJAX call and populating the Select2.</p>
  
  <p>Now I want in some other code a way to get all the values inside the Select2.</p>