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

On change problem #35

Closed
fredw opened this issue Dec 18, 2014 · 4 comments · Fixed by #37
Closed

On change problem #35

fredw opened this issue Dec 18, 2014 · 4 comments · Fixed by #37
Labels

Comments

@fredw
Copy link

fredw commented Dec 18, 2014

I'm with a problem in the onchange trigger of select.
While I'm doing research via ajax the on change trigger of the select is called multiple times.
The "on change" should be done differently?
I'm placing down the script I made for my test environment to simulate the error:

<select name="country" class="form-control" required="required" data-live-search="true"></select>

<script>

    $(document).ready(function() {

        $('select[name=country]').selectpicker().ajaxSelectPicker({
            cache: false,
            preserveSelected: false,
            ajaxOptions: {
                url: 'http://beta.json-generator.com/api/json/get/HPmtU2d',
                type: 'POST',
                dataType: 'json',
                data: function () {

                    var params = {
                        q: '{{{q}}}'
                    };

                    return params;
                }
            }
        }).on('change', function() {
            console.log('Changed!');
        });
    });

</script>
@truckingsim
Copy link
Owner

We are triggering a internal refresh on both ajax success and ajax complete. This internal refresh event (which also calls bootstrap-selects refresh) triggers a change event.

Unless @MarkCarver has time before me, and I know he's been slammed, I won't have time to fix this until after December 23rd.

@truckingsim
Copy link
Owner

@fredw sorry it took so long but the 1.3.1 branch I think will fix your problem. If it doesn't let me know and I'll re-open this and try to come up with something better.

@adrm
Copy link

adrm commented Dec 13, 2016

@truckingsim I can reproduce this bug on 1.8.1. onchange event is firing every time the ajax search completes, even before selecting anything.

@pudjamansyurin
Copy link

same problem with @adrm, no solution yet

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

Successfully merging a pull request may close this issue.

4 participants