example usage ;
<script>
function myFunction() {
var car = {type:"Fiat", model:"500", color:"white"};
dmx.app.set('car', car);
}
</script>
example usage ;
<script>
function myFunction() {
var car = {type:"Fiat", model:"500", color:"white"};
dmx.app.set('car', car);
}
</script>
I’ve read it completely, but since i’m not a JS coder I cannot make it work with my script. I could if I need to set a variable from wappler to the script, but not the other way around
Wappler variables can be accessed using dmx.app.data. Assuming the variable is at the root of your page, then:
dmx.app.data.vuFp.value
I’ve wrote this:
<dmx-value id="myVariable" dmx-bind:value="dmx.app.data.vuFp.value"></dmx-value>
But didn’t fetch the variable from the JS
What I provided is when you need a wappler variable within javascript
If your variable is not in the root of your page, then you have to use this method suggested by patrick
Try typing dmx.app.data.vuFp.value in your browser console, if it comes with undefined, then probably it’s nested in your page…
It’s the other way around. I need to get the varible from the JS not inside the JS.
Doesn’t Serhat’s solution work for you?
You add a variable component in your page, set the value of the same from JS like this:
dmx.parse(‘var_test.setValue(‘12345’)’);
If your variable is not in the root, you must use the full path like this:
dmx.parse(‘repeat1.items[7].var_test.setValue(‘12345’)’);
and use the variable within your page as usual.
The single quote at the end is too curved, try editing it in wappler, usually happens when you copy paste it from other editors.
Also if vuFp was in fact a string, then enclose it within single quotes.
What do you get if you type dmx.app.data.myVariable in your browser console?
You have type next to the >
I get: {$type: “value”, value: null, __setValue: ƒ}
Is app connect framework added on your page?
Are you sure you know how the things work? Do you have any basic js knowledge?
Now type, dmx.parse('myVariable.setValue("vuFp")')
, press enter
Then, check the variable’s value again by running, dmx.app.data.myVariable
Using dmx.parse(‘myVariable.setValue(“vuFp”)’) works, but sets the value to “vuFp” and not the actual variable value