Created
October 17, 2016 13:16
-
-
Save juliorosseti/e245e511a1e7adcdf15d547326a4f7c3 to your computer and use it in GitHub Desktop.
Change selectpicker in "silviomoreto/bootstrap-select/issues/737" solution
This file contains 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
<select class="form-control selectpicker" name="mynames[]" | |
multiple="multiple" onchange="changeSelectPicker(this)"> | |
<option value="1">Count 1</option> | |
<option value="2">Count 2</option> | |
<option value="3">Count 3</option> | |
<option value="4">Count 4</option> | |
</select> | |
<script type="text/javascript"> | |
// PROBLEM | |
$('.selectpicker').on("changed.bs.select", function (e, clickedIndex) { | |
console.log(this); // NO RETURN | |
}); | |
// PROBLEM | |
$('.selectpicker').on("change", function (this) { | |
console.log(this); // NO RETURN | |
}); | |
// SOLVED | |
function changeSelectPicker(that) { | |
var valuesArr = $(that).val(); | |
console.log(valuesArr); // return selected values ["1", "3", "4"] | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment