title: How to enable infinite scrolling in select2 4.0 without ajax
body: <p>I am using <code>select2</code> with custom data adapter. All of the data provided to <code>select2</code> is generated locally in web page (so no need to use ajax). As <code>query</code> method can generate a lot of results (about 5k) opening select box  is quite slow. </p>
  
  <p>As a remedy, I wanted to use infinite scroll. <a href="https://select2.github.io/options.html" rel="noreferrer">Documentation</a> for custom data adapter says that <code>query</code> method should receive <code>page</code> parameter together with <code>term</code>:</p>
  
  <blockquote>
    <p>@param params.page The specific page that should be loaded. This is
    typically provided when working with remote data sets, which rely
    on pagination to determine what objects should be displayed.</p>
  </blockquote>
  
  <p>But it does not: only <code>term</code> is present. I tried to return <code>more: true</code> or <code>more: 1000</code>, but this didn't help. I guess this is because, by default, <a href="https://github.com/select2/select2/blob/master/src/js/select2/defaults.js#L123" rel="noreferrer">infinite scroll is enabled iff ajax is enabled</a>.</p>
  
  <p>I am guessing that enabling infinite scroll will involve using <code>amd.require</code>, but I am not sure what to do exactly. I tried this code:</p>
  
  <pre><code>$.fn.select2.amd.require(
      ["select2/utils", "select2/dropdown/infiniteScroll"],
      (Utils, InfiniteScroll) =&gt;
        input.data("select2").options.options.resultsAdapter = 
          Utils.Decorate(input.data("select2").options.options.resultsAdapter, InfiniteScroll)
  )
  </code></pre>
  
  <p>This is coffee script, but I hope that it is readable for everyone. <code>input</code> is <code>DOM</code> element containing select box - I earlier did <code>input.select2( //options )</code></p>
  
  <p>My question is basically, how do I enable infinite scroll without <code>ajax</code>? </p>