So I`m trying to bind a value to a HTML input type="checkbox" element by using vuejs2 v-model, by calling a JQuery Ajax 'get' function. The value binds correctly the first time, but afterwards it does nothing, It also deselect the input type="checkbox".
...<input type="checkbox" id="notification" class="custom-control-input" v-model="checked" />...
... <button class="btn btn-primary" type="button" onclick="getSettings()">Update</button>...
<script>
function getSettings()
{
$.ajax({
type: "GET",
url: "../../handler/getSettings.ashx",
contentType: "application/json; charset=utf-8",
data: {
},
async:false,
success: function (result) {
var app = new Vue({
el: '#notification',
data: {
checked: result.Notification
}
});
console.log(app.checked);
},
error: function (err) {
}
});
};
</script>
I expect the to be selected, but if I rerun (for the second time and onward) the code (by calling getSettings()) the input type="checkbox" deselect and stays deselected. I can confirm that the code get executed, due to the fact that the console log return a 'true'.