Bug #7457
closedAdding an invisible WDateEdit and WGoogleMap causes a JavaScript error
0%
Description
Somehow, the new WPopupWidget...
JavaScript code ends up being executed before the loading of WPopupWidget.js
. This seems to be related to the fact that WGoogleMap
require()
s some new JavaScript, causing the WPopupWidget.js
code to be placed into the ScriptLibrary.beforeLoadJS
.
Files
Updated by Roel Standaert almost 5 years ago
- File issue_7457.cpp issue_7457.cpp added
Updated by Roel Standaert almost 5 years ago
- File issue_7457.cpp issue_7457.cpp added
Updated by Roel Standaert almost 5 years ago
Note: this also happens when a WDateEdit
and WGoogleMap
are both created and added to the root at the same time when e.g. reacting to some signal.
Updated by Roel Standaert almost 5 years ago
So this is what I see happening:
-
LOAD_JAVASCRIPT(...)
runs in WPopupWidget, adding it toWApplication::newJavaScriptToLoad_
-
setJavaScriptMember(...)
runs in WPopupWidget, adding the code to run toWWebWidget::otherImpl_->jsStatements_
for thatWPopupWidget
-
WGoogleMap
usesWApplication::require
to load the Google JavaScript API, which, throughstreamBeforeLoadJavaScript -> streamJavaScriptPreamble
causes theLOAD_JAVASCRIPT
code to be placed intobeforeLoadJS
for thatScriptLibrary
. -
WebRenderer::collectJS
collects the JavaScript from WPopupWidget'sWWebWidget::otherImpl_->jsStatements_
first (which containsnew WPopupWidget
) - Then the
loadScriptLibraries
code is run, which contains the declaration ofWPopupWidget
.
Now to figure out how things should work instead. I wonder why we're loading script libraries after collecting the JavaScript of the changes?
Updated by Roel Standaert almost 5 years ago
- Status changed from New to Resolved
I pushed a commit that should fix this: WApplication::require()
should not be used from the render()
function, so I moved it to the constructor of WGoogleMap
.
Updated by Roel Standaert almost 5 years ago
- Status changed from Resolved to Closed