This is my Razor view.
@Html.TextBoxFor(a => a.wellModel.APINumber, new { id = "apiselect2" })
This is my script to get the selected value from select2:
$(document).ready(function () {
$("#apiselect2").on("select2-selecting", function () {
alert($("#apiselect2").select2('data').text);
});
});
For some reason it only shows it to me once and if I change from let's say selected value 777 to 321 no alert is displayed.
I also tried to change this to:
$("#apiselect2").on("change", function () { ...
Still nothing. Really appreciate any help on this.