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

Paging together with multiple selections not working #23

Open
cdietze opened this issue Jun 10, 2015 · 2 comments
Open

Paging together with multiple selections not working #23

cdietze opened this issue Jun 10, 2015 · 2 comments

Comments

@cdietze
Copy link

cdietze commented Jun 10, 2015

I have a select2 element that gets its data via ajax paged from the server. The select element shall allow multiple selections.
Selecting elements from page 1 works fine.
However, when selecting elements from page > 1 they appear briefly in the input box and then dissappear.
From scanning the source code I think whats happening is that a query request with search terms = "" is issued (without page field so my server returns page 1). Then the current viewValues are filtered by the result, so anything not on the first page gets ditched. This is the code block where that happens: https://github.com/rubenv/angular-select2/blob/master/src/select2.js#L199

Am I doing something wrong with my query function? Or is this a bug?

@cdietze
Copy link
Author

cdietze commented Jun 10, 2015

I hacked together a workaround:
I store all retrieved items in an array (a set actually because I check for duplicates). Then essentially I do this in the query function:

if(query.page === undefined) {
    query.callback({
        results: allData
    });
    return;
}

@tyaslab
Copy link

tyaslab commented Jul 9, 2015

+1 Experiencing same issue, but instead of iterating options, I iterated optionItems in getSelection(callback) function.

#26

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

No branches or pull requests

2 participants