title: How to reset the data after init , Select2
body: <p>I use <a href="https://select2.github.io/" rel="nofollow noreferrer">Select2-4.0.0</a> I have been struggling with this problem for a whole day that to update the data. </p>
  
  <p>I search every posts I can like <a href="https://stackoverflow.com/questions/16480910/update-select2-data-without-rebuilding-the-control">Update select2 data without rebuilding the control</a>, but none have them work.</p>
  
  <p>What I need is really simple (a setter to data):</p>
  
  <p>I have a diaglog, which had a select. Every time I open the diaglog, I will ajax for an data to keep it in a local array like:</p>
  
  <p>when dialog open :</p>
  
  <pre><code>    var select2List=syncToLoadTheData();//data for select2
      $('#search-user-select').select2({  //here when secondly executed, the select2's data on UI does not refreshed 
          data:select2List,
          matcher: function(params, data){
              var key = params.term;
              if ($.trim(key) === '') {
                  return data;
              }
              if( (matchKeyAndPinyin(key,data.text))){
                  return data;
              }
              return null;
          }
      }
  </code></pre>
  
  <p>But the problem is even though the list is changing, the select options does not change at all.Please note in my test case, every time i open the dialog, the data from server is changed:</p>
  
  <p>What I had tried:
  1.when init:</p>
  
  <pre><code>  data: function() { return {results: select2List}; }// not work to show any data at all
  </code></pre>
  
  <p>2.when secondly open dialog:</p>
  
  <pre><code>  $( "#search-user-select").select2('data',newdata,true);//not work to have the new data
  </code></pre>
  
  <p>3.when secondly open:</p>
  
  <pre><code>   $("#search-user-select").select2("updateResults");//Error, does not have this method
  </code></pre>
  
  <p>And some other method like directly change the array's data(only one copy of the data), but none of them work.</p>