toggleEnable(event) {
let shouldEnable = event ? event.target.checked : false
if (typeof event === 'boolean') {
this.isEnabled = event;
}
if (shouldEnable !== this.autoCampaign.enabled) {
this.updateSettings({
enabled: shouldEnable
})
}
},
<div id="switch-wrapper">
<span>enabled</span>
<span class="switch">
<input name="auto_campaign[enabled]" type="hidden" value="0">
<input id="enabled" class="switch-input" type="checkbox" value="1"
name="auto_campaign[enabled]" v-model="isEnabled"
@change="toggleEnable" />
<label class="switch-paddle enable-button" for="enabled"></label>
</span>
</div>
Issue with the code is The status is displayed always as "enabled" even if the toggle is off. But i need to show a separate message as The status should be "disabled" when the toggle is on OFF position.
I saw that this can be achieved through v-if and v-else. but not sure how to proceed