title: Select2 with AJAX and Initial Local Data
body: <p>So I'm trying to get the select2 plugin to work with a Backbone.js / CakePHP app. The idea is that this select2 holds email addresses for contacting people as tasks become completed, but the form is editable. What I want to do is (1) load / display all the already saved email addresses for the task being edited, and (2) I want to still have the select2 perform AJAX searches to list recognized emails.
  I keep having this issue where I can either show initial data, OR have the AJAX search feature.</p>
  
  <p>My current code for my select2 box is a Backbone.View, and it looks like:</p>
  
  <pre><code>define([
      'backbone',
      'jquery',
      'jquery.select2'
  ],
  function(Backbone, $, select2) {
  
      var notificationSelector = Backbone.View.extend({
  
          notifications: undefined,
  
          events: {
              'change' : 'select2ContactsChanged'
          },
  
          initialize: function(attrs) {
              this.collection.on('add remove reset', this.render(), this);
              this.select2ContactsChanged(); 
          },                              
  
          render: function() {
  
              var contacts = ["abc@def.com", "joe@banana.com"];
              $('.notification-selector').attr('value', contacts);
  
  
  
              if(this.select2Control == undefined) 
              {
                  // Do Search() + query here
                  this.select2Control = this.$el.select2({
                      width: '200px',
                      placeholder: '@email',
                      tags: [],
                      minimumInputLength: 3,
  
                      // initSelection: function(element, callback) {
                      //  return $.ajax({
                      //      type: "GET",
                      //      url: "/notifications/fetch/",
                      //      dataType: 'json',
                      //      data: { id: (element.val()) },
                      //      success: function(data) {
  
                      //      }
                      //  }).done(function(data) {
                      //      console.log(data);
                      //  });
                      // },
  
                  });
              }
              else
              {
                  // Do Search() + query here
                  this.select2Control = this.$el.select2({
                      width: '200px',
                      placeholder: '@email',
                      tags: [],
                      minimumInputLength: 3,
  
                      ajax: {
                          url: '/notifications/search/',
                          dataType: 'json',
                          data: function(term, page) {
                              return {
                                  SearchTerm: term
                              };
                          },
  
                          results: function(data, page) {
                              return {
                                  results: data
                              };
                          }
                      }
                  });
              }
  
          },
  
          select2ContactsChanged: function() {
              var contacts = this.select2Control.val().split(',');
              this.collection.reset(contacts);
          }
  
      });
  
      return notificationSelector;
  });
  </code></pre>
  
  <p>I read a response by the creator of Select2 to someone else (<a href="https://github.com/ivaynberg/select2/issues/392" rel="nofollow">https://github.com/ivaynberg/select2/issues/392</a>) in which he says to use a 'custom query' to achieve what seems to be what I want. I'm having trouble finding relevant examples or making enough sense of the docs to figure out what he means. 
  Can anyone spot what I'm doing wrong / missing?</p>
  
  <p>Thanks for your time!</p>
  
  <p>EDIT
  I forgot to mention -- the DOM element this is attached to is <code>&lt;input type="hidden" multiple="true" class="notification-selector select2-result-selectable"&gt;&lt;/input&gt;</code></p>