-
-
Notifications
You must be signed in to change notification settings - Fork 363
Open
Labels
confirmed bugSomething isn't workingSomething isn't workingfrontendThe frontend interfaceThe frontend interfaceneeds discussionA decision needs to be taken by the dev teamA decision needs to be taken by the dev team
Milestone
Description
page.js.twig currently sets the page Javascript variable to import page-specific variables from the server into the client JS environment. However it looks like in some cases we load this partial both in the base page as well as dynamic components such as modal forms.
This means that the original value set in the base page gets completely overwritten when the modal form is loaded.
The simplest solution seems to be merging, rather than setting, the page variable by changing page.js.twig:
{# Page variables needed by client-side code (Javascript). #}
{% autoescape 'js' %}
if (typeof page === 'undefined') {
var page = {};
}
page = $.extend(
true, // deep extend
{{ page | json_encode(constant('JSON_PRETTY_PRINT')) | raw }},
page
);
{% endautoescape %}
This doesn't completely guarantee that nested values in page won't be overwritten, of course. But it at least provides a mechanism for easily setting additional client-side variables while keeping them scoped under the top-level page object.
Metadata
Metadata
Assignees
Labels
confirmed bugSomething isn't workingSomething isn't workingfrontendThe frontend interfaceThe frontend interfaceneeds discussionA decision needs to be taken by the dev teamA decision needs to be taken by the dev team
Type
Projects
Status
References