An issue arises with the simple show and hide functionality on the loading element while executing a Vue js function.
The Vue js function is designed to perform certain tasks and update data upon completion. In an attempt to display a loading animation during this process, I have simplified the process by using a basic loop for discussion purposes, eliminating other potential issues such as ajax or async operations.
Here is the HTML code for the button:
<button type="button" v-on:click="DoStuff()">Do Stuff</button>
And here is the corresponding vue js code:
var client = new Vue({
el: '#client',
data: {
someData: []
},
methods: {
DoStuff: function() {
//Show Loader
$(".loader").show();
//Simulate delay
for (var i = 0; i < 100000000; i++) {
var x = i;
}
//Hide loader
$(".loader").hide();
// Notify user when done.
alert('Task complete');
}
However, the loader fails to appear. If I disable the hide command, the loader appears only after the alert, indicating a possible underlying asynchronous operation despite not intentionally implementing any async procedures.