Skip to content

Commit

Permalink
#5 - problem with flags - fix
Browse files Browse the repository at this point in the history
Fix is only in bootstrap-select-country.js
It must also be loaded into *.min.js file, but i do not know how :)
  • Loading branch information
vladimirbiro authored and mojoaxel committed Feb 26, 2020
1 parent 17ee311 commit 1c96c20
Showing 1 changed file with 1 addition and 12 deletions.
13 changes: 1 addition & 12 deletions src/bootstrap-select-country.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,22 +33,11 @@ let countrypicker = function(opts) {
$.each(countries, function (index, country) {
options.push(`<option
data-tokens="${country.code}"
data-icon="inline-flag flag ${country.code}.toLowerCase()"
class="option-with-flag"
value="${country.code}">${country.name}</option>`);
});

/* after bootstrap-select finished loading add flogs to every option-btn */
$select.on('loaded.bs.select', function (e) {
$('a.option-with-flag').each(function() {
var $optionBtn = $(this);
if ($optionBtn.children('.inline-flag').length <= 0) {
var code = $optionBtn.data('tokens').toLowerCase();
var $flag = $(`<span class="inline-flag flag ${code}"></span>`);
$optionBtn.prepend($flag);
}
});
});

/* after bootstrap-select finished loading or selection changed add flag to the select btn */
$select.on('loaded.bs.select change', function (e) {
/* which country-codes are selected? */
Expand Down

0 comments on commit 1c96c20

Please sign in to comment.