Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple, closeOnSelect=false, infinite - doesn't load more when select2-more-results comes into view #1613

Closed
timkingman opened this issue Aug 13, 2013 · 2 comments

Comments

@timkingman
Copy link

When using infinite scroll with remote data on a multiple:true, closeOnSelect:false select2, if I click on all of the results in the first page, the "Loading more results..." item comes into view but doesn't actually trigger an ajax load of second page.

Example:
From the select2 examples page, run in the javascript console:

$("#e7").select2("destroy");
$("#e7").select2({
            closeOnSelect:false, multiple:true,
            placeholder: "Search for a movie",
            minimumInputLength: 3,
            ajax: {
                url: "http://api.rottentomatoes.com/api/public/v1.0/movies.json",
                dataType: 'jsonp',
                quietMillis: 100,
                data: function (term, page) { // page is the one-based page number tracked by Select2
                    return {
                        q: term, //search term
                        page_limit: 10, // page size
                        page: page, // page number
                        apikey: "ju6z9mjyajq2djue3gbvv26t" // please do not use so this example keeps working
                    };
                },
                results: function (data, page) {
                    var more = (page * 10) < data.total; // whether or not there are more results available

                    // notice we return the value of more so Select2 knows if more results can be loaded
                    return {results: data.movies, more: more};
                }
            },
            formatResult: movieFormatResult, // omitted for brevity, see the source of this page
            formatSelection: movieFormatSelection, // omitted for brevity, see the source of this page
            dropdownCssClass: "bigdrop", // apply css that makes the dropdown taller
            escapeMarkup: function (m) { return m; } // we do not want to escape markup since we are displaying html in results
        });

Then search for "Terminator". Without scrolling, click on each result. As the results move from the result list to a selected choice, you'll eventually get down to one result and "Loading more results...", but the second page of results doesn't get loaded.
If you had instead scrolled to show "Loading more results...", the second page loads as expected, the only problem is when "Loading more results..." appears because you have selected items off the top of the list

@hasryan
Copy link

hasryan commented Oct 23, 2013

I am experiencing the same issue when using a custom query function to load paginated results.

@alexweissman
Copy link
Contributor

@hasryan can you confirm if this is the same issue causing either #4417 or #3088?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants