Dynamic JavaScript on EvaluateJS

Hello, I am trying to make dynamic JavaScript push on the webview by EvaluateJS

for example, my evaluateJS code is

<OnUserEvent EventName="myGlobalEvent">
  <EvaluateJS JavaScript="{InjectJs}" />

and the initial InjectJs is

var InjectJs = Observable("$('body').prepend('<hr>heelo</hr>');");

And it makes ‘heelo’ message and hr line on the top of the body,

next, I want change the InjectJs Dynamically, so I change the value of the InjectJs and check the value

InjectJs.value = "$('body').prepend('<hr>second value</hr>');"

when I check the value of InjectJs by console.log, it changed properly,

HOWEVER, when I triggered UserEvent again, the value was not changed.

its output is still ‘heelo’, the initial value of InjectJS.

I tried several ways to change the JavaScript Value of EvaluateJS

  1. Change it on embeded .js as above
  2. make ux:Global(Injector) on EvaluateJS and make Change on Injector.JavaScript
  3. Make the InjectJs normal variable (not observable) and change it
  4. Make the InjectJs global variable and change it

but nothing works… the initial value of JavaScript seems static…

Is there any other way to change the initial JavaScript Value of EvaluateJS


For the sake of troubleshooting, could you post a small project showing this behavior?


Liam Svanåsbakken Crouch wrote:


For the sake of troubleshooting, could you post a small project showing this behavior?


Hello!! sorry to reply late, I uploaded my project below

if you wanna test the evaluateJS operation, You should

  1. click the filter on the first page
  2. click to toggle any box and click apply button, then the webview render many product boxes
  3. click one box and new page will be loaded with new webview
  4. click the native Heart button on bottom-right, and click back button on top-left
  5. then you can see the EvaluateJS operated and the initial Javascript injected on the main webview
    (when the EvaluateJS fired, the value of Javascript Changed, but the injecting Javascript is static)

I hope some solution exist!