title: Replacing select2 options?
body: <p>All,</p>
  
  <p>I have two select boxes :</p>
  
  <ul>
  <li>Fruit select</li>
  <li>FruitQuantity select</li>
  </ul>
  
  <p>Depending on what option is selected in Fruit will affect the options of FruitQuantity.</p>
  
  <p>So using select2, I wanted to replace all the options in a select simply by doing this.</p>
  
  <pre><code>var options = [];
              $.each(pageData.products[selectedFruit].quantities, function (key, value) {
                  options.push({
                      text: value.quantity,
                      id: value.quantity,
  
                  })
              });
              console.log(options.length);
              $quantitySelect.select2( { data : options });
  </code></pre>
  
  <p>The problem is that select2 is just appending the new data on to what exists already. I want it to clean out all the options and add the new ones.</p>
  
  <p>Otherwise my select box is filling up with incorrect options.</p>
  
  <p>I tried this from this question <a href="https://stackoverflow.com/questions/13240047/clear-dropdown-using-jquery-select2">Clear dropdown using jQuery Select2</a></p>
  
  <pre><code>$quantitySelect.select2('data', null)
  </code></pre>
  
  <p>This does nothing though, it doesn't clear it.</p>
  
  <p>Help me Obi Wan, you're my only hope.</p>