Select2 ne pas utiliser mes templateResults ou templateSelection options

Je suis en train d'utiliser le select2 appel ajax à l'aide de modèles. Je reçois à l'ajax en seulement beaux, mais il n'est pas à l'aide de mon modèle de fonctions.

l'ajax données est:

[
   {"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"}
]

la select2 code (que j'ai pris beaucoup de ici ) est:

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 = "<h1>" + data.name + "</h1>" + "<p>" + data.otherData + "</p>";

          return markup;
        }

        function formatDataSelection (data) {
          return data.name;
        }


    }
};

L'erreur que je reçois est Uncaught TypeError: Cannot read property 'toUpperCase' of undefined sur la ligne 356 de select2.js pour la Version: 3.5.2.

Il me semble que select2 n'est pas à l'aide de mon templateSelection et templateResults fonction.

OriginalL'auteur Bwata | 2015-03-19