jeudi 28 septembre 2017

Exporting VueJS-rendered HTML with checkbox fails to preserve checked state

My component template contains the following checkbox code:

<div ref="htmlData">
    <input 
        type="checkbox" 
        class="mycb" 
        :id="uniqID" 
        :disabled="disabled"
        v-model="cbvalue"
    >
</div>

(parts removed for simplicity).

I need to create a PDF out of this template (on server). This is what i'm doing in the code:

methods : {
    save () {
        let saveData = {
              'html': this.$refs.htmlData.innerHTML 
            };
        this.$http.post('/api/save',saveData);
    }
}

However, the saved HTML doesn't contain checkbox state, so it always saves an unchecked checkbox.

Here's a slightly modified jsfiddle.

My question is: how can I capture the checkbox state in the rendered HTML?

I tried adding :checked="cbvalue" prop - no luck




Aucun commentaire:

Enregistrer un commentaire