Commits

John Lenz committed a1ff25a

select2: directly use createSearchChoice and initSelection instead of tags option to be able to support ajax

  • Participants
  • Parent commits aeb24d2

Comments (0)

Files changed (1)

File templates/compose.julius

 
     // Now the address fields
     $(".address-field").each(function() {
-        var addrs = $(this).val().split(",");
         $(this).select2({
-            tags: addrs,
+            data: [],
+            multiple: true,
             tokenSeparators: [","],
+            createSearchChoice: function(term) {
+                return {id: term, text: term};
+            },
+            initSelection: function(element, callback) {
+                var data = []
+                $(element.val().split(",")).each(function() {
+                    data.push({id: this, text: this});
+                });
+                callback(data);
+            },
             escapeMarkup: function(m) { return m; },
             formatResult: function(addr) {
                 if (addr.id != "") {