0

I use ajax remoteCommand component with Primefaces and this component updates inputHidden field with boolean value.

I call JS function on the onsuccess event of remoteCommand but it seems that my function is called before DOM update because when I test inputHidden value, this is not the right value but if I set interval to test 3s after, I have the right value...

Code :

<p:remoteCommand process="..." onsuccess="hideOrShowNotification();" />

First JS test :

function hideOrShowNotification(){
   alert($('#tabView\\:register_form\\:hiddenNotification').val()); 
}

Second JS test :

function hideOrShowNotification(){
  setInterval(function(){alert($('#tabView\\:register_form\\:hiddenNotification').val());}, 3000);  
}

In first case I receive false value and in second case I receive true value. The expected value is true.

So my DOM is not fully loaded when my JS function is called.

How can I call JS function after full loading of DOM ? I believed onsuccess event would do that but no apparently.

Olivier J.
  • 3,115
  • 11
  • 48
  • 71

1 Answers1

2

Ok...it's the oncomplete event. I tested it before but perhaps I have forgotten to clear browser cache to reload new JS file.

EDIT : link to primefaces tag documentation

Olivier J.
  • 3,115
  • 11
  • 48
  • 71