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

Refresh not working after append option selected ajax #112

Closed
baskara8 opened this issue Apr 21, 2017 · 0 comments
Closed

Refresh not working after append option selected ajax #112

baskara8 opened this issue Apr 21, 2017 · 0 comments

Comments

@baskara8
Copy link

baskara8 commented Apr 21, 2017

Hi,
I have a problem, to display selected option at first position after append option using ajax, it always show emptyTitle (Select and Begin Typing) at first. not selected option at first

Below my code

$(document).find("#modal_villages #villages_districtsid").selectpicker().ajaxSelectPicker({
    ajax: {
        url: URL,
        dataType: 'json',
    },
    locale: {
        emptyTitle: 'Select and Begin Typing'
    },
    log: 3,
    preprocessData: function(data) {
        var i, l = data.length,
            arr = [];
        if (l) {
            for (i = 0; i < l; i++) {
                if (data[i].districts_id.toLowerCase().indexOf(this.plugin.query) != -1 || data[i].districts_desc.toLowerCase().indexOf(this.plugin.query) != -1) {
                    arr.push($.extend(true, data[i], {
                        text: data[i].districts_desc,
                        value: data[i].districts_id,
                        data: {
                            subtext: data[i].districts_regenciesname
                        }
                    }));
                }
            }
        }
        // You must always return a valid array when processing data. The
        // data argument passed is a clone and cannot be modified directly.
        return arr;
    }
});
$(document).find("#modal_villages #villages_districtsid").append('<option value="' + $(this).data("districtsid") + '" data-subtext="' + $(this).data("districtsname") + '" selected="selected">' + $(this).data("districtsname") + '</option>').selectpicker('refresh');

image

truckingsim added a commit that referenced this issue Jun 26, 2017
commit a6bc84d14a6e9e7fe7fb38b434c910c80aeefcee
Author: Adam Heim <[email protected]>
Date:   Mon Jun 26 17:03:11 2017 -0400

    Fix spacing of elseif

commit 7e9b2ef6029ec61d26c2e5c3c4f03bc02b6bf701
Merge: 7992293 a18f92d
Author: Adam Heim <[email protected]>
Date:   Mon Jun 26 17:00:28 2017 -0400

    Merge branch 'master' into bercut497-fix_selectedTextFormat

commit 79922930156de6c61e2bd1ce18ef85510f5c4c22
Merge: a6a562f 19344e0
Author: Adam Heim <[email protected]>
Date:   Mon Jun 26 16:32:41 2017 -0400

    Merge branch 'fix_selectedTextFormat' of git://github.com/bercut497/Ajax-Bootstrap-Select into bercut497-fix_selectedTextFormat

commit a6a562fb822f28e114f002b5f944e3d291b23ddb
Merge: 2571a0b 63c6c98
Author: Adam Heim <[email protected]>
Date:   Mon Jun 26 16:30:11 2017 -0400

    Merge branch 'master' into bercut497-fix_selectedTextFormat

commit 19344e0
Merge: 9d0f9c3 07feb52
Author: bercut <bercut>
Date:   Tue Jun 27 01:27:54 2017 +0500

    Merge branch 'fix_selectedTextFormat' of github.com:bercut497/Ajax-Bootstrap-Select into fix_selectedTextFormat

commit 9d0f9c3
Author: Bercut Stray <[email protected]>
Date:   Sun Jun 25 13:49:49 2017 +0500

    fix #22  if element title attribute not set - option.selectedTextFormat will never be restored

commit 2571a0ba4a7b50210a0356acfdab98e21aa4a14e
Merge: c486bf0 7f28ef0
Author: Adam Heim <[email protected]>
Date:   Mon Jun 26 15:06:25 2017 -0400

    Merge branch 'master' into bercut497-fix_selectedTextFormat

commit c486bf034a9065462169148c1bc331503fbdca54
Merge: dce492d 07feb52
Author: Adam Heim <[email protected]>
Date:   Mon Jun 26 14:50:31 2017 -0400

    Merge branch 'fix_selectedTextFormat' of git://github.com/bercut497/Ajax-Bootstrap-Select into bercut497-fix_selectedTextFormat

commit 07feb52
Author: Bercut Stray <[email protected]>
Date:   Sun Jun 25 13:49:49 2017 +0500

    fix #22 #112. if element title attribute not set - option.selectedTextFormat will never be restored

commit 27230cd
Author: Bercut Stray <[email protected]>
Date:   Sun Jun 25 13:44:27 2017 +0500

    Revert "ignore bower components"
    prepare clean branch
    This reverts commit fbab292.

commit dee3337
Author: bercut <bercut>
Date:   Fri Jun 23 00:15:38 2017 +0500

    add api-docs js

commit c7245f1
Author: bercut <bercut>
Date:   Fri Jun 23 00:14:31 2017 +0500

    fix option.selectedTextFormat object link. generate dist files. regerate docs

commit 6308c00
Author: bercut <bercut>
Date:   Thu Jun 22 23:38:50 2017 +0500

    fix check and restore selectedTextFormatOption

commit fbab292
Author: bercut <bercut>
Date:   Thu Jun 22 23:34:30 2017 +0500

    ignore bower components
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