From 48d392635f9037da6f797e4f525cc9239eaa3c6b Mon Sep 17 00:00:00 2001
From: Sebastian Kather <sebastian.kather@gmail.com>
Date: Thu, 16 Jan 2014 16:12:00 +0100
Subject: [PATCH] singleSelect: setting nextSearchTerm in initSelection

For single select the nextSearchTerm callback is called when
initSelection returned data
---
 select2.js | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/select2.js b/select2.js
index 8040d281..43d1d3f5 100644
--- a/select2.js
+++ b/select2.js
@@ -762,6 +762,8 @@ the specific language governing permissions and limitations under the Apache Lic
             // dom it will trigger the popup close, which is not what we want
             this.dropdown.on("click mouseup mousedown", function (e) { e.stopPropagation(); });
 
+            this.nextSearchTerm = undefined;
+			
             if ($.isFunction(this.opts.initSelection)) {
                 // initialize selection based on the current value of the source element
                 this.initSelection();
@@ -789,8 +791,7 @@ the specific language governing permissions and limitations under the Apache Lic
             this.autofocus = opts.element.prop("autofocus");
             opts.element.prop("autofocus", false);
             if (this.autofocus) this.focus();
-
-            this.nextSearchTerm = undefined;
+            
         },
 
         // abstract
@@ -2144,9 +2145,10 @@ the specific language governing permissions and limitations under the Apache Lic
                         self.updateSelection(selected);
                         self.close();
                         self.setPlaceholder();
+                        self.nextSearchTerm = self.opts.nextSearchTerm(selected, self.search.val());
                     }
                 });
-            }
+            }			
         },
 
         isPlaceholderOptionSelected: function() {