1
Good staff,
I needed to change the return value by clicking the button, i.e., first the click
would have to return false
and past x segundos
would have to return true
and proceed with the event.
The code is as follows::
$(".btnnext").on("click",function (e) {
if (newText != "" || newText2 != "" || newText3 != "" || newText4 != "") {
var teste = false;
setTimeout((function () {
teste = true;
console.log(teste);
$(".btnnext").trigger("click");
return teste;
}), 2000);
return teste;
}});
My approach was to first return false and later with the function setTimeout
change the return value and simulate the click again on the button.
Problem: The return value is changed but the event does not advance, the second click does not work.
What I want is that when you click the button, for example, when you go from step 2 to step 3, it takes one x seconds
The question is what logic are you trying to achieve with this ? Because it will certainly have simpler and more direct forms for such
– Isac
@Isac I believe there is a simpler way, this was only my approach if there is an easier/better direct. The main goal is to click the stop button on the event caused by it (stay in the same DOM x seconds) and then advance.
– Adriano Maia
Explain in visual words and things what you want to happen, not how you’re trying to solve the problem. You want to click a button and have it stay a few seconds on the page and then be removed ?
– Isac
It is best to use ajax to make the request to the backend and only when you get the response of ajax refreshes the page and/or navigates to another location. So he does everything as he’s supposed to and without skulking.
– Isac
@Isac the problem here is the change of the DOM from the button, the click on the button is that triggers the accounts and how the domain changes the accounts do not come out correct. I really need to click the button, "delay" your action a little.
– Adriano Maia
How are you triggering the start of doing the math in the backend? Can you add that information to the answer? It seems to me that the @Isac suggestion is ideal, when clicking the button, asking AJAX and when you receive the result from the server, redirects the user to the next page.
– Leite
I was wrong, I mean, with
backend
wanted to say the click of the button that is represented in the code. I just did not put it because it is a little long... So the same click triggers the accounts and the change of theDOM
.– Adriano Maia