Set value to variable by javascript

Hello,

I am facing something strange…

My project is with NodeJS

  1. A single page with a variable “var1” (dafault = Hello World).
  2. A title showing the value of “var1.value” on the page.
  3. A button, when clicking, I execute a javascript function (setTitle) that is at the bottom of the page.

This approach doesn’t work, am I missing something?


function setTitle() {
    dmx.app.set('var1', 'OTHER TITLE');
}

And it gets even more complicated, when I have a page using a layout, in this case, the layout has an area where the pages are injected, like this.


    <%- await include(content, locals); %>

In this case, it creates an extra level inside “dmx.app.data”, so how do I define the value of a variable that is on my internal page? I tried that, but it also doesn’t work.


function setTitle() {
    dmx.app.set('content.var1', 'OTHER TITLE');
}

Community Page
Last updated: