title: Select2 not using my templateResults or templateSelection options
body: <p>I am trying to use the select2 ajax call with templates. I am getting the ajax in just fine but it is not using my template functions.</p>
  
  <p>the ajax data is:</p>
  
  <pre><code>[
     {"name":"First thing","otherData":"asdfg"},
     {"name":"Second thing","otherData":"qqerr"},
     {"name":"third thing","otherData":"yerty"},
     {"name":"fourth thing","otherData":"hgjfgh"},
     {"name":"fifth thing","otherData":"fhgkk"}
  ]
  </code></pre>
  
  <p>the select2 code (which i took a lot from <a href="https://select2.github.io/examples.html">here</a> ) is:</p>
  
  <pre><code>FundSearch = {
      create: function (selector, theURL) {
        $(selector).select2({
          ajax: {
            url: theURL,
            dataType: 'json',
            delay: 250,
            data: function (params) {
              console.log(params.term);
              return {
                q: params.term, // search term
                page: params.page
              };
            },
            results: function (data, page) {
              // parse the results into the format expected by Select2.
              // since we are using custom formatting functions we do not need to
              // alter the remote JSON data
              return {
                results: data
              };
            },
            cache: true
          },
          escapeMarkup: function (markup) { return markup; }, // let our custom formatter work
          minimumInputLength: 1,
          templateResult: formatData,
          templateSelection: formatDataSelection
        });
  
        function formatData (data) {
            if (data.loading) return data.name;
  
            markup = "&lt;h1&gt;" + data.name + "&lt;/h1&gt;" + "&lt;p&gt;" + data.otherData + "&lt;/p&gt;";
  
            return markup;
          }
  
          function formatDataSelection (data) {
            return data.name;
          }
  
  
      }
  };
  </code></pre>
  
  <p>The error I am getting is <code>Uncaught TypeError: Cannot read property 'toUpperCase' of undefined</code> on line 356 of <code>select2.js</code> for Version: 3.5.2.</p>
  
  <p>It seems to me that select2 is not using my templateSelection and templateResults function.</p>