title: How do I fire a new ajax on select2 new /remove tag event?
body: <p>I use the following snippet to add a new <a href="http://ivaynberg.github.io/select2/" rel="nofollow noreferrer">select2</a> tag remotely with ajax and I want to register or remove some records of my many to many table on new tag / remove tag event</p>
  
  <p>The Table looks like</p>
  
  <pre><code>---------------------------------
  +--voucher_id--+|+--product_id--+
  ---------------------------------
  +     123       |   566         +
  ---------------------------------
  +     156       |   566         +
  ---------------------------------
  +     123       |   426         +
  ---------------------------------
  +     156       |   516         +
  ---------------------------------
  </code></pre>
  
  <p>My Javascript</p>
  
  <pre><code>$(".e6").select2({
      tags: true,
      placeholder: 'placeholder',
      minimumInputLength: 1,
  
      ajax: {
          url: 'searchProducts',
          dataType: 'json',
          data: function(term) {
              return {q: term};
          },
          results: function(data) {
              return {results: data};
          }
      },
      createSearchChoice: function(term, data) {
          if ($(data).filter(function() {
              return this.computername.localeCompare(term) === 0;
          }).length === 0) {
              return {id: term, name: term};
          }
      },
      formatResult: function(item, page) {
          return item.computername;
      },
      formatSelection: function(item, page) {
          return item.computername;
      }
  });
  </code></pre>
  
  <p>In the returned json I have a product ID as well and I'm searching a way to fire a new ajax on select2 event but I can't figure out where should be done to save or remove data from my table.</p>
  
  <p>Making some researches I've been able to build a function which would update records on the table above and which is working good sofar</p>
  
  <pre><code>$('.e6').on("change", function(e){                           
      console.log(ids);
      console.log(gs);
      $.ajax({
          type: "POST",
          url: '/admin/?controller=vouchers&amp;action=updateRelatedProducts',
          data: {ids: ids, gs:gs},
          error: function () {
              alert("error");
          }
      });                   
  });
  </code></pre>
  
  <p>But I have problems to populate my input field with initial existing tags </p>