Hi everyone,


 I am currently implementing some JS logic at a client's webapp, now, at some point, I need to call a screen action, I have a button that I click with JS.

 The thing is that the button wont actually be called until the whole JS is finished, when in fact, what we need is to call the server action immediately when the button.click() happens and then continue the flow of the function in JS!

 Can someone please explain how to achieve this?

Thanks.

Hi Guilherme,

Use the following pattern to implement what you want to achieve: 

The return false statement will make the override of the default behavior of the button


Br

Domingues wrote:

Hi Guilherme,

Use the following pattern to implement what you want to achieve: 

The return false statement will make the override of the default behavior of the button


Br


Hi Domingues, 

 I am not sure I understand your solution!
 But maybe it's because I did not explain the situation as well as I should:

1- We have a web app

2- There is some javascript at the screen level

3- In that JS there is a main function which contains several functions inside

   3.1 - Lets say we have 5 sub function, and sub function 1 calls two and two call three etc...

4- One of the sub functions inside of the main function clicks a button in the screen with the click() method

5- Lets say sub function 2 is the one that clicks the button!


 Case: If the user activatates the main function what will happen is that the whole function and their sub functions will run ( including the one that clicks the button) but the server action is not called until the whole main function ends.


What we want: Calling the main function and running the sub function 2 clicks the button which imediatly calls the server action, only after calling the server action does sub function 3,4 .... continue ( assynchronously from the server action)