I am messing around with UIBuilder and decided to try to learn VueJS. My coding skills in Javascript/html/css are basic, at best.
I think my issue is more VueJS than NodeRed, but not 100% sure. I started this project building right off the "simple vuejs example" in UIBuilder that already had the functions to pass messages to NodeRed.
So rough example of what I am trying to do, say I need to pass 10 first and last names to NodeRed:
<div v-for="n in 10">
<label :for="'fname'+[n]">First Name</label>
<input type="text" :id="'fname'+[n]" :name="'fname'+[n]" :v-model="'fname'+[n]">
<label :for="'lname'+[n]">Last Name</label>
<input type="text" :id="'lname'+[n]" :name="'lname'+[n]" :v-model="'lname'+[n]">
</div>
<b-button id="SaveNames" v-on:click="SendNames">Save</b-button>
In my index.js file I have:
SendNames: function () {
// Set topic and send message
var topic = this.msgRecvd.topic || 'OMS/SendNames'
uibuilder.send({
'topic': topic,
'payload': {
'fname1': this.fname1,
'lname1': this.lname1,
'fname2': this.fname2,
'lname2': this.lname2,
'fname3': this.fname3,
'lname3': this.lname3,
etc...
Using this, if I click the "Save" button... all the values show up in the NodeRed debug, but all values are blank.
Now, if I get rid of the v-for loop, and the dynamic names and just hard code everything.. it works perfectly.
<div>
<label for="fname1">First Name</label>
<input type="text" id="fname1" name="fname1" v-model="fname1">
<label for="lname1">Last Name</label>
<input type="text" id="lname1" name="lname1" v-model="lname1">
<label for="fname2">First Name</label>
<input type="text" id="fname2" name="fname2" v-model="fname2">
<label for="lname2">Last Name</label>
<input type="text" id="lname2" name="lname2" v-model="lname2">
<label for="fname3">First Name</label>
<input type="text" id="fname3" name="fname3" v-model="fname3">
<label for="lname1">Last Name</label>
<input type="text" id="lname3" name="lname3" v-model="lname3">
(etc etc etc)
</div>
<b-button id="SaveNames" v-on:click="SendNames">Save</b-button>
Any values typed into the input fields passes through properly this way....
I'd MUCH rather use the v-for loop, but I cannot figure out why the values start passing blank. If anyone has some insight, or a direction I should research, I'd appreciate it.