Just trying to access the selected text (not value) of a select element via Vue:
var App = window.App = new Vue({
el: '#app',
data: {
style: '5'
},
computed: {
calctitle: function() {
return this.otype.text;
}
}
});
Just an example style object:
$item = new stdClass();
$item->value = 5;
$item->text = 'Name 1';
$style = array($item);
...
Here i try to create a binding because if i don't cannot submit the form because the option value is "[object Object]", but i need the real int value.
<p>{{calctitle}}</p>
<select v-model="style" name="style">
<option>Choose style</option>
<?php foreach ($style as $item) : ?>
<option value="<?php echo $item->value; ?>" v-bind:otype="{value: <?php echo $item->value; ?>, text: '<?php echo $item->text; ?>'}"><?php echo $item->text; ?></option>
<?php endforeach ?>
</select>