OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

Checkbox state does not change

  • Thread starter Thread starter Amr
  • Start date Start date
A

Amr

Guest
`I am using vue3 with options api`

For the code posted below, I have a checkbox that when checked, the method onCheckboxGeoTIFFOverlayBandAveragesChanged() should be executed. Despite I check and uncheck the the checkbox several times, the log statement in onCheckboxGeoTIFFOverlayBandAveragesChanged always displays that the valus of isCheckboxGeoTIFFOverlayBandAveragesChecked is false.

please let me know why that is happening and how to solve it

code:

Code:
<template>
    <cds-checkbox id="idCheckboxGeoTIFFOverlayBandAveragesContainer">
        <label id="idTextGeoTIFFOverlayBandAverages">{{ tempTextBandAverages }}</label>
        <input
            type="checkbox"
            :value="compPropsVModelCheckGeoTIFFOverlayBandAverages"
            @input="$emit('update:compPropsVModelCheckGeoTIFFOverlayBandAverages', $event.target.checked)"
            :disabled="isCheckboxGeoTIFFOverlayBandAveragesDisabled"
            :checked="isCheckboxGeoTIFFOverlayBandAveragesChecked"
            @change="onCheckboxGeoTIFFOverlayBandAveragesChanged"
        />
    </cds-checkbox>
</template>

<script>
import { GeoTIFFOverlaySettingsConstants } from '../../../resources/GeoTIFFOverlaySettings/GeoTIFFOverlaySettingsConstants.js';

let msg = null;

export default {
    name: 'SentinelHubGeoTIFFOverlayBand1',
    data() {
        return {
            tempTextBandAverages: GeoTIFFOverlaySettingsConstants.CONST_STRING_BAND_1_AVERAGES.description,
        };
    },
    components: {},
    props: {
        isCheckboxGeoTIFFOverlayBandAveragesChecked: {
            type: Boolean,
            default: false,
        },
        isCheckboxGeoTIFFOverlayBandAveragesDisabled: {
            type: Boolean,
            default: false,
        },
        vModelCheckGeoTIFFOverlayBandAverages: {
            type: Boolean,
            default: null,
        },
    },
    emits: {
        'update:vModelCheckGeoTIFFOverlayBandAverages': null,
    },
    computed: {
        compPropsVModelCheckGeoTIFFOverlayBandAverages: {
            get() {
                return this.vModelCheckGeoTIFFOverlayBandAverages;
            },
            set(value) {
                this.$emit('update:vModelCheckGeoTIFFOverlayBandAverages', value);
            },
        },
    },
    methods: {
        onCheckboxGeoTIFFOverlayBandAveragesChanged() {
            msg = JSON.stringify({msg:verboseTag + '@watch.', isChecked: this.isCheckboxGeoTIFFOverlayBandAveragesChecked});
            console.log(msg);
        },
    },
};
</script>

<p>`I am using vue3 with options api`</p>
<p>For the code posted below, I have a <code>checkbox</code> that when checked, the method <code>onCheckboxGeoTIFFOverlayBandAveragesChanged()</code> should be executed. Despite I check and uncheck the the <code>checkbox</code> several times, the log statement in <code>onCheckboxGeoTIFFOverlayBandAveragesChanged</code>
always displays that the valus of <code>isCheckboxGeoTIFFOverlayBandAveragesChecked</code> is false.</p>
<p>please let me know why that is happening and how to solve it</p>
<p><strong>code</strong>:</p>
<pre><code><template>
<cds-checkbox id="idCheckboxGeoTIFFOverlayBandAveragesContainer">
<label id="idTextGeoTIFFOverlayBandAverages">{{ tempTextBandAverages }}</label>
<input
type="checkbox"
:value="compPropsVModelCheckGeoTIFFOverlayBandAverages"
@input="$emit('update:compPropsVModelCheckGeoTIFFOverlayBandAverages', $event.target.checked)"
:disabled="isCheckboxGeoTIFFOverlayBandAveragesDisabled"
:checked="isCheckboxGeoTIFFOverlayBandAveragesChecked"
@change="onCheckboxGeoTIFFOverlayBandAveragesChanged"
/>
</cds-checkbox>
</template>

<script>
import { GeoTIFFOverlaySettingsConstants } from '../../../resources/GeoTIFFOverlaySettings/GeoTIFFOverlaySettingsConstants.js';

let msg = null;

export default {
name: 'SentinelHubGeoTIFFOverlayBand1',
data() {
return {
tempTextBandAverages: GeoTIFFOverlaySettingsConstants.CONST_STRING_BAND_1_AVERAGES.description,
};
},
components: {},
props: {
isCheckboxGeoTIFFOverlayBandAveragesChecked: {
type: Boolean,
default: false,
},
isCheckboxGeoTIFFOverlayBandAveragesDisabled: {
type: Boolean,
default: false,
},
vModelCheckGeoTIFFOverlayBandAverages: {
type: Boolean,
default: null,
},
},
emits: {
'update:vModelCheckGeoTIFFOverlayBandAverages': null,
},
computed: {
compPropsVModelCheckGeoTIFFOverlayBandAverages: {
get() {
return this.vModelCheckGeoTIFFOverlayBandAverages;
},
set(value) {
this.$emit('update:vModelCheckGeoTIFFOverlayBandAverages', value);
},
},
},
methods: {
onCheckboxGeoTIFFOverlayBandAveragesChanged() {
msg = JSON.stringify({msg:verboseTag + '@watch.', isChecked: this.isCheckboxGeoTIFFOverlayBandAveragesChecked});
console.log(msg);
},
},
};
</script>
</code></pre>
 
Top