Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

When a subdialog changes variables, why doesn the calling dialog see them?

0
10 Posted

When a subdialog changes variables, why doesn the calling dialog see them?

0

When a subdialog and the calling dialog share the same application root, developers often ask why changes to application variables made by the subdialog aren’t visible in the calling dialog after the subdialog returns, and why they aren’t visible if the same subdialog is called later in the application. The reason is that each subdialog gets its own, newly-initialized copy of the application and document scopes each time it’s called. This means that if the first invocation of the subdialog makes a change to a document-scope variable, the change gets thrown away as soon as the subdialog returns and its copy of the document scope goes away. The second invocation (and even the caller) never see the changed variable, because they have their own copies of all the variables. One workaround is to have the subdialog return the new value of the variable, and have its caller stash that in a variable somewhere for use next time it’s called. Another solution would be to have the subdialog generate

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.