0

I am pretty new to vue, and am trying to use it in a bootstrap modal. The relevant div in the modal is as follows.

<div class="form-group row">
    <label for="priceQCField" class="col-sm-2 col-form-label">Price<span class="red"> *</span></label>
    <input type="number" step="0.01" class="form-control col-sm-4" id="priceQCField" name="priceQCField" min="0" v-model="job.price">   
</div>

I read some other questions about vue returning strings rather than numbers, so I have converted the job.price to a number inside my method to call the modal

showPriceJob: function (job) {
    this.job = job;
    this.job.price = parseFloat(this.job.price);
    $('#mdlPriceJob').modal('show');
},

However, job.price refuses to appear in the input field either as a string or a number. I know it is available to the modal as I can see it using <span>{{job.price}}</span>.

Can anyone advise me please?

Additional - I think it is a display issue - if I change the input field, the entry in the <span> changes

2nd update - initial table

<tr class="light-grey" v-for="job in jobs" v-on:click="viewJob(job)">
    <td>{{job.id}}</td>
    <td>{{job.customerName}}</td>
    <td>{{job.description}}</td>
    <td v-bind:class="job.dueDate | dateColour">{{job.dueDate | dateOnly}}</td>
    <td>&pound;{{job.price}} {{job.isEstimate | priceEstimated}}</td>
    <td>{{job.delivery}}</td>
</tr>
Nik White
  • 1
  • 3

1 Answers1

0

Upd.

According to your comments to my answer you are using v-for and you can't use this.job within your method. You should give us more code to see the whole picture.

Upd.2

You have showed more code but I didn't see any v-for so I am confused. You can try to use something like this if job is a property of appData.jobs:

        showPriceJob: function (job) {
            this.appData.jobs.job = Object.assign({}, job);
            this.appData.jobs.job = parseFloat(this.appData.jobs.job.price);
            $('#mdlPriceJob').modal('show');
        },

But I'm not sure about this because I don't see where job is declared.

Upd.3

Oh! Wait! You have this code:

data: appData.jobs, but data should be in this format:

data: function(){
    return {
        appData: {
            jobs: [],
        },
    }
},

Or show me what is your appData.jobs variable is.

webprogrammer
  • 2,393
  • 3
  • 21
  • 27