@@ -12029,7 +12029,7 @@ define('select2/data/ajax',[
1202912029 var $request = $ . ajax ( options ) ;
1203012030
1203112031 $request . success ( function ( data ) {
12032- var results = self . processResults ( data ) ;
12032+ var results = self . processResults ( data , params ) ;
1203312033
1203412034 callback ( results ) ;
1203512035 } ) ;
@@ -12395,14 +12395,18 @@ define('select2/dropdown/infiniteScroll',[
1239512395
1239612396 InfiniteScroll . prototype . append = function ( decorated , data ) {
1239712397 this . $loadingMore . remove ( ) ;
12398+ this . loading = false ;
1239812399
12399- decorated . call ( this , data ) ;
12400+ if ( $ . isArray ( data ) ) {
12401+ decorated . call ( this , data ) ;
12402+ return ;
12403+ }
12404+
12405+ decorated . call ( this , data . results ) ;
1240012406
12401- if ( data . length > 0 ) {
12407+ if ( this . showLoadingMore ( data ) ) {
1240212408 this . $results . append ( this . $loadingMore ) ;
1240312409 }
12404-
12405- this . loading = false ;
1240612410 } ;
1240712411
1240812412 InfiniteScroll . prototype . bind = function ( decorated , container , $container ) {
@@ -12421,12 +12425,12 @@ define('select2/dropdown/infiniteScroll',[
1242112425 } ) ;
1242212426
1242312427 this . $results . on ( 'scroll' , function ( ) {
12424- var loadMoreVisible = $ . contains (
12428+ var isLoadMoreVisible = $ . contains (
1242512429 document . documentElement ,
1242612430 self . $loadingMore [ 0 ]
1242712431 ) ;
1242812432
12429- if ( self . loading || ! loadMoreVisible ) {
12433+ if ( self . loading || ! isLoadMoreVisible ) {
1243012434 return ;
1243112435 }
1243212436
@@ -12451,6 +12455,10 @@ define('select2/dropdown/infiniteScroll',[
1245112455 this . trigger ( 'query:append' , params ) ;
1245212456 } ;
1245312457
12458+ InfiniteScroll . prototype . showLoadingMore = function ( _ , data ) {
12459+ return data . pagination && data . pagination . more ;
12460+ } ;
12461+
1245412462 InfiniteScroll . prototype . createLoadingMore = function ( ) {
1245512463 var $option = $ (
1245612464 '<li class="option load-more" role="treeitem"></li>'
0 commit comments