Why does RunJavascript run in Infinite Loop?

Why does RunJavascript run in Infinite Loop?

  

I have a Web Block which uses Javascript


It works fine as expected. But I noticed that when I press the "STOP" button, it goes into INIFINTE ACTIVATING THE STOP ACTION button.

You will notice this on the bottom right of the page:

My FakeNotifyWidget:

Inside RunJavascrip of FakeNotifyt:

"
 timeStop = document.getElementsByClassName('values')[0].innerHTML;
            timer.stop();
"


My Javascript for the Timer WebBlock:

"
       var timer = new Timer();
       var timeStop;
     
        $('#"+chronoExample.Id+" .startButton').click(function () {
            timer.start();
         
        });
        $('#"+chronoExample.Id+" .pauseButton').click(function () {
            timer.pause();
        });
        $('#"+chronoExample.Id+" .stopButton').click(function () {
            timeStop = document.getElementsByClassName('values');
            timer.stop();
             OsNotifyWidget("+fakeNotifyWidget.Id+", timeStop);
         
        });
        $('#"+chronoExample.Id+" .resetButton').click(function () {
            timer.reset();
        });
        timer.addEventListener('secondsUpdated', function (e) {
            $('#chronoExample .values').html(timer.getTimeValues().toString());
        });
        timer.addEventListener('started', function (e) {
            $('#chronoExample .values').html(timer.getTimeValues().toString());
        });
        timer.addEventListener('reset', function (e) {
            $('#chronoExample .values').html(timer.getTimeValues().toString());
        });  
     
"

My HTML for the Timer WebBlock:


"
  <div id=""chronoExample"">
       <h1>   <div class='values'>00:00:00</div> </h1>
  </div>
"
    

Hello Rey,

Well...
How can we know? ;) 

I mean, we do not know your code. So, I think no one will be able to give you an answer, unless you provide more information and context.

Cheers.

Hi Rey,

Can you provide more information on the code, sharing the OML for example?

Regards,

Rey Anthony Renacia wrote:

I have a Web Block which uses Javascript


It works fine as expected. But I noticed that when I press the "STOP" button, it goes into INIFINTE ACTIVATING THE STOP ACTION button.

You will notice this on the bottom right of the page:

My FakeNotifyWidget:

Inside RunJavascrip of FakeNotifyt:

"
 timeStop = document.getElementsByClassName('values')[0].innerHTML;
            timer.stop();
"


My Javascript for the Timer WebBlock:

"
       var timer = new Timer();
       var timeStop;
     
        $('#"+chronoExample.Id+" .startButton').click(function () {
            timer.start();
         
        });
        $('#"+chronoExample.Id+" .pauseButton').click(function () {
            timer.pause();
        });
        $('#"+chronoExample.Id+" .stopButton').click(function () {
            timeStop = document.getElementsByClassName('values');
            timer.stop();
             OsNotifyWidget("+fakeNotifyWidget.Id+", timeStop);
         
        });
        $('#"+chronoExample.Id+" .resetButton').click(function () {
            timer.reset();
        });
        timer.addEventListener('secondsUpdated', function (e) {
            $('#chronoExample .values').html(timer.getTimeValues().toString());
        });
        timer.addEventListener('started', function (e) {
            $('#chronoExample .values').html(timer.getTimeValues().toString());
        });
        timer.addEventListener('reset', function (e) {
            $('#chronoExample .values').html(timer.getTimeValues().toString());
        });  
     
"

My HTML for the Timer WebBlock:


"
  <div id=""chronoExample"">
       <h1>   <div class='values'>00:00:00</div> </h1>
  </div>
"
    


Hi,


what i see from your code, you are calling the fake notify on timer stop, and inside notify action you are doing timer start?(from label timerstart)


your code:

 $('#"+chronoExample.Id+" .stopButton').click(function () {
            timeStop = document.getElementsByClassName('values');
            timer.stop();
             OsNotifyWidget("+fakeNotifyWidget.Id+", timeStop);
         
        });


Can you try removing "OsNotifyWidget", what are you tring to do in notify action?, and check if working after removing.


Thanks,

Balu



OsNotifyWidget is placed inside that JS code because I want to FETCH the value from a Javascript file and pass it to an Outsystem LOCAL variable as there seems to be no other way to do this. FakeNotify is that bridge, the mediator, which connects JS and Outsystems so so they can pass variables to each other. Do you have a better method?