I wonder if anyone might be able to point me at a more complete example of using custom matchers in the Beta of select2 than the one on the examples page at
https://select2.github.io/examples.html as I seem to be missing something in my code.
I'm loading the Javascript in my page thus:
<script src="
https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script src="/pubs/javascript/Standard/optional/select2.amd.js"></script>
<script src="/pubs/javascript/combined.js"></script> // my site JS
Then wrapping my selector with:
$.select2.amd.require(['select2/compat/matcher'], function (oldMatcher)
{
var t = $('#townselect').select2(
{
matcher: oldMatcher(matchStart),
placeholderOption:'first'
});
});
function matchStart (term, text)
{
if (text.toUpperCase().indexOf(term.toUpperCase()) === 0)
{
return(true);
}
return(false);
}
But when I try to run the code I get the following errors:
11:45:02.034 ReferenceError: define is not defined select2.amd.js:1:0
11:45:04.041 TypeError: $.select2 is undefined combined.js:1458:2
trying the same thing using select2.full.js, I get:
11:58:04.749 TypeError: $.select2 is undefined combined.js:1458:2
I also tried changing "$.select2.amd.require" to "$.select2.full.require" and even "$.select2.require" in case this was necessary, but with no change.
I'm obviously missing something that should be obvious to me, but even studying the source of the examples page hasn't helped.
I'd be grateful for any pointers to get me in the right direction.