# Dynamic JavaScript on EvaluateJS

**URL:** <https://forums.fusetools.com/t/dynamic-javascript-on-evaluatejs/584>\
**Category:** General\
**Created:** [August 29, 2017, 5:19am UTC](https://forums.fusetools.com/t/dynamic-javascript-on-evaluatejs/584 "2017-08-29T05:19:48Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dwno31](https://avatars.discourse-cdn.com/v4/letter/d/a5b964/32.png) [@dwno31](https://forums.fusetools.com/u/dwno31)\
**Post date:** [August 29, 2017, 5:19am UTC](https://forums.fusetools.com/t/dynamic-javascript-on-evaluatejs/584/1 "2017-08-29T05:19:48Z")

</div>

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

for example, my evaluateJS code is

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

```

and the initial InjectJs is

```auto
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

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

```

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

---

<div class="post-metadata">

**Author:** ![petterroea](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/petterroea/32/438_2.png) [@petterroea](https://forums.fusetools.com/u/petterroea)\
**Post date:** [August 29, 2017, 5:57pm UTC](https://forums.fusetools.com/t/dynamic-javascript-on-evaluatejs/584/2 "2017-08-29T17:57:48Z")

</div>

Hello

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

Liam

---

<div class="post-metadata">

**Author:** ![dwno31](https://avatars.discourse-cdn.com/v4/letter/d/a5b964/32.png) [@dwno31](https://forums.fusetools.com/u/dwno31)\
**Post date:** [September 3, 2017, 6:25am UTC](https://forums.fusetools.com/t/dynamic-javascript-on-evaluatejs/584/3 "2017-09-03T06:25:01Z")

</div>

> **Liam Svanåsbakken Crouch wrote:**
> 
> Hello
> 
> For the sake of troubleshooting, could you post a small project showing this behavior?
> 
> Liam

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

> **[GitHub - dwno31/mariazu\_alph: for Fuse](https://github.com/dwno31/mariazu_alph)**
>
> for Fuse . Contribute to dwno31/mariazu\_alph development by creating an account on GitHub.

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!  
thnx!
