Created
November 27, 2018 09:56
-
-
Save MohamedLamineAllal/38eb4fa77fff720f94e383ecce013717 to your computer and use it in GitHub Desktop.
Boiler plate and example for jquery and pure js manipulation of select boxes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//example using select2 pluging (don't forget .trigger('change.select2')) | |
phoneCodeSelect.on('change', function () { | |
let countryName = $(this).find('option:selected').eq(0).text().replace(/\(.*\)/, '').trim().toUpperCase(); | |
countrySelect.val(countryName).trigger('change.select2');; | |
// countrySelect.find('option:selected').prop('selected', false); | |
// countrySelect.find('option[value=' + $(this).find('option:selected').eq(0).text().replace(/\(.*\)/, '').trim().toUpperCase() + ']').prop('selected', true); | |
console.log('ssssssssssssssssssssssssssssssssssss'); | |
console.log($(this).find('option:selected').eq(0).text().replace(/\(.*\)/, '').trim().toUpperCase()); | |
console.log(countrySelect); | |
console.log('sssssssssssssssssssssssssssssssssssssss'); | |
cc_bloodHound.clear(); | |
cc_bloodHound.add(countriesCities[ucwords(countryName)]); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment