Hey,
how do I get the text value from a selected option? I am using vue.js, and what function so ever I try, all I get is the ID, not the text.
This is the code:
<select2 v-model="bereichId"
:options="bereiche" name="ed_kbid" id="ed_kbid">
</select2>
watch:
bereichId: function(input){
console.log("Input0: " + this.bereichId);
var regex1 = /\d/g;
var regex2 = /\D/g;
var bed1 = regex1.test(input);
var bed2 = regex2.test(input);
var theSelection = $("ed_kbid").select2('data').text;
console.log(theSelection);
console.log("Select: " + $("#ed_kbid").text(theSelection));
if(bed1 && (theSelection == ''))
{
if(bed2)
{
console.log("Input1: " + input);
this.$store.commit('setBereichInput', input)
}
else
{
console.log("Input2: " + input);
input = input.replace(input, '');
this.bereichId = input;
}
}
else
{
console.log("Input3: " + input);
this.$store.commit('setBereichInput', input)
}
}
Any help is appreciated!