title: Select2 templateResult data has no element to reference
body: <p>I'm attempting to append text to any new value added in a <code>select2</code> with <code>freeform</code> text option.  The text appended I want to set on the select element <em>(in my case by way of an mvc helper)</em>.  </p>
  
  <p>The issue is that the data coming into the templateResult doesn't have an element.  Everywhere I've searched, data.element is used to get into the DOM, but it's not there for me and I'm not sure why.  If I look in the createTag function the params also has no element.  Also the container is just an "li" apparently not yet in the dom, no children or parents.</p>
  
  <p><strong>Here is code:</strong></p>
  
  <pre><code>$('.custom-dropdown').each(function() {
    $(this).css('width', '100%');
    if ($(this).hasClass('freeform')) {
      $(this).select2({
          tags: true,
          createTag: function(params) {
            return {
              id: params.term,
              text: params.term,
              newOption: true
            }
          },
          templateResult: function(data, container) {
            var $result = $("&lt;span&gt;&lt;/span&gt;");
  
            $result.text(data.text);
  
            if (data.newOption) {
              //data.element is undefined here!!!
            }
          }
  
          return $result;
        },
        placeholder: "Press ENTER for list of options",
        allowClear: true,
        selectOnClose: true
      });
  } else {
    $(this).select2({
      placeholder: "Press ENTER for list of options",
      allowClear: true,
      selectOnClose: true,
    });
  }
  
  $(this).on('select2:select', function(e) {
    if (e.params.data.text != '') {
  
      var id = $(this).attr('id');
      var select2 = $("span[aria-labelledby=select2-" + id + "-container]");
      select2.removeAttr('style');
    }
  
  }); $(this).on('select2:close', function() {
    $(this).focus();
  });
  
  });
  </code></pre>
  
  <p>An example of the select would be:</p>
  
  <p>select <code>class="custom-dropdown freeform"</code> <code>data-appendme="blorg"</code></p>