title: Select2: Creating tags with ajax
body: <p>I am using the select2 library.</p>
  
  <p>My select2 element can search the database for each tag via the ajax and that works fine.</p>
  
  <p>My issue is, I want the user to also be able to create a new tag. Looking at their documentation I should use the <code>createTag</code> option; however, this fires as soon as I click into the element and on each key press. </p>
  
  <p>Can anyone offer any guidance on how I can achieve my goal?</p>
  
  <p>here is my code thus far</p>
  
  <pre class="lang-js prettyprint-override"><code>I am using ajax top search for tags but I would also like to create new tags to the database. I have tried doing this via createTag but this seems to be firing as soon as I click in the HTML element and on each key press.
  
  Here is my code:
  
                $('.tags').select2({
                tags: true,
                placeholder: "These tags will apply to all lines",
                tokenSeparators: [','],
                ajax: {
                    url: '/api/tags/find',
                    dataType: 'json',
                    data: function (params) {
                        return {
                            q: $.trim(params.term)
                        };
                    },
                    processResults: function (data) {
                      return {
                          results: data
                      }
                    },
                    cache: true,
                },
                createTag: function(params) {
                    alert('tag created') // This is were I would put my ajax POST. 
                }
            });
  
  </code></pre>