Customizing how results are matched
  
    Unlike other dropdowns on this page, this one matches options only if
    the term appears in the beginning of the string as opposed to anywhere:
  
  
    This custom matcher uses a
    compatibility module that is
    only bundled in the
    full version of Select2. You also
    have the option of using a
    more complex matcher.
  
  
{% highlight js linenos %}
function matchStart (term, text) {
  if (text.toUpperCase().indexOf(term.toUpperCase()) == 0) {
    return true;
  }
  return false;
}
$.fn.select2.amd.require(['select2/compat/matcher'], function (oldMatcher) {
  $(".js-example-matcher-start").select2({
    matcher: oldMatcher(matchStart)
  })
});
{% endhighlight %}