I have a toggle button that changes isActive
to true
or false
but it won’t change the button. I have to refresh the page to show the color change in the toggle button.
I’m new to vue.js. Please any advice? Thanks in advance!
async toggleNetworkGroup(audId, netId, turnOn)
{
let status = { isActive: turnOn };
let url = projConfig.apiRoot + `/s/groups/${audId}/network-groups/${netId}`;
console.log(status);
return axios.put(url, status)
.then((res) =>
{
if(!this.isActive)
{
this.isActive = true;
return { success: res };
}
else if (this.isActive)
{
this.isActive = false;
return res;
}
})
.catch((error) =>
{
console.log(error);
});
<switcher
:value="networkAudience.isActive"
:disabled="loading"
@input="(isChecked) => toggleNetworkGroup(isChecked, group.id, networkGroup.name, networkGroup.id)"
/>