RunJavaScript don't run

  

Hi

I have some toubles in doing a thing with my Environment with the java script, i put a container with a action on change, inside that action i have a Assing widget and a RunJavaScript Widget, the debugger pass for all widgets, but never execute the "RunJavaScript"

I have already try to use a Server Action and a widget_click to a button (Ajax Submit) that will have the javascript and nothing work.

The console logs does't even show in Google Chorme Console.

Someone have this problem already that can help me?

Greetings Pedro Vieira



Hi pmmv999

I like your message in the JavaScript ;)

Anyway, the JavaScript will execute in the browser, not in the Server. It will be sent back to the browser as the response to the request made.

Are you looking for the console during the debug or after the action executed?

Cheers

Is the screen action triggering? Did you debug and check if the "OpenTabNumber" assignment in your screen action is triggering?

I just make a small test (a button with submit to the ScreenAction with the RunJavaScript) and everything works:

I have one more suggestion:

1. Extract all the JS code into a function (and define some required parameters)

2. Define this JS function on your screen level.

3. From OutSystems, call this JS function using the "RunJavascript" - and just call the function.


Advantage is:

1. You don't have to paste raw javascript in the "RunJavascipt", you simply call a function with required params.

2. Debugging JS in browser becomes easier. When you go to Chrome console, just do F12, and go to sources.

If your screen name is "MyScreen", the JS will be inside "MyScreen.js" . You can then set breakpoints etc in the JS and chrome browser will help in debugging.

Haha thanks ;)

I looking the Console after the server action execute i know that javascript only run after sending response to browser

Solution

pmmv999 wrote:

Haha thanks ;)

I looking the Console after the server action execute i know that javascript only run after sending response to browser

lol
Sorry.

In any case, I just did a test and the JavaScript was executed.
Did you try with only the concole.log part? Just to guarantee that is not a problem with the rest of the JavaScript?

Cheers.


Solution

Eduardo Jauch no problem  :D
Thanks for trying to help


Chetan Yewale wrote:

I have one more suggestion:

1. Extract all the JS code into a function (and define some required parameters)

2. Define this JS function on your screen level.

3. From OutSystems, call this JS function using the "RunJavascript" - and just call the function.


Advantage is:

1. You don't have to paste raw javascript in the "RunJavascipt", you simply call a function with required params.

2. Debugging JS in browser becomes easier. When you go to Chrome console, just do F12, and go to sources.

If your screen name is "MyScreen", the JS will be inside "MyScreen.js" . You can then set breakpoints etc in the JS and chrome browser will help in debugging.

Okay the problem is the next:

I test what you said to me set the fuction JavaScript on screen i am executing the program and program flow stop


$([document.documentElement, document.body]).animate({
        scrollTop: $('#' + divs[OpenTabNumber].id).offset().top;
}, 500);

I delete this part and the program work again, conclusion:

This part have a sintex error but never show in console i use this

   var windowHeight = $(window).height()/2;          
    $('html,body').animate({
        scrollTop: $('#' + elemId).offset().top-windowHeight
    },100);


Sry for my bad English

Greetings Pedro Vieira